Пример #1
0
 def store_media(self, filename, mediafile):
     """Store media files."""
     filename = os.path.join(
         self.img_dir,
         filename
     )
     fileops.create_dirs(
         os.path.dirname(filename)
     )
     mediafile.fetch_to_file(filename)
Пример #2
0
 def store_media(self, filename, mediafile):
     """Store media files."""
     temp_filename = os.path.join('/tmp', filename)
     fileops.create_dirs(os.path.dirname(temp_filename))
     mediafile.fetch_to_file(temp_filename)
     s3_key = Key(self.bucket)
     s3_key.key = os.path.join(
         '/images', "%s.%s" % (filename, mediafile.fileext)
         if mediafile.fileext is not None else filename)
     s3_key.set_contents_from_filename(mediafile.filename)
     os.remove(mediafile.filename)
     mediafile.filename = s3_key.generate_url(expires_in=0,
                                              query_auth=False)
Пример #3
0
 def store_media(self, filename, mediafile):
     """Store media files."""
     temp_filename = os.path.join(
         '/tmp',
         filename
     )
     fileops.create_dirs(
         os.path.dirname(temp_filename)
     )
     mediafile.fetch_to_file(temp_filename)
     s3_key = Key(self.bucket)
     s3_key.key = os.path.join(
         '/images',
         "%s.%s" % (filename, mediafile.fileext)
         if mediafile.fileext is not None
         else filename
     )
     s3_key.set_contents_from_filename(
         mediafile.filename
     )
     os.remove(mediafile.filename)
     mediafile.filename = s3_key.generate_url(
         expires_in=0, query_auth=False
     )
Пример #4
0
 def store_media(self, filename, mediafile):
     """Store media files."""
     filename = os.path.join(self.img_dir, filename)
     fileops.create_dirs(os.path.dirname(filename))
     mediafile.fetch_to_file(filename)