Commits

Anonymous committed 8d2bc19

support creating files via storage.open(name, 'w')

  • Participants
  • Parent commits 3a53e65

Comments (0)

Files changed (1)

storages/backends/s3boto.py

         self.name = name[len(self._storage.location):].lstrip('/')
         self._mode = mode
         self.key = storage.bucket.get_key(self._storage._encode_name(name))
+        if not self.key and 'w' in mode:
+            self.key = storage.bucket.new_key(storage._encode_name(name))
         self._is_dirty = False
         self._file = None
 
 
     def close(self):
         if self._is_dirty:
+            self._file.seek(0)
             self.key.set_contents_from_file(self._file,
                 headers=self._storage.headers, policy=self._storage.acl)
         self.key.close()