示例#1
0
 def create_and_save_doc(self, new_file, video):
     if FILEPICKER:
         homedir, created = UserFolder.objects.get_or_create(
             name='home',
             owner=video.owner)
         videodir, created = UserFolder.objects.get_or_create(
             name='%s' % video.slug,
             owner=video.owner)
         document = CustomFileModel(
             folder=videodir,
             created_by=video.owner
         )
         document.file.save(
             os.path.basename(new_file),
             File(open(new_file, "rb")),
             save=True)
         document.save()
     else:
         document = CustomFileModel()
         document.file.save(
             os.path.basename(new_file),
             File(open(new_file, "rb")),
             save=True)
         document.save()
     return document
示例#2
0
 def create_and_save_image(self, new_file, video):
     """Create and save image."""
     if FILEPICKER:
         homedir, created = UserFolder.objects.get_or_create(
             name='home', owner=video.owner)
         videodir, created = UserFolder.objects.get_or_create(
             name='%s' % video.slug, owner=video.owner)
         image = CustomImageModel(folder=videodir, created_by=video.owner)
         image.file.save(os.path.basename(new_file),
                         File(open(new_file, "rb")),
                         save=True)
         image.save()
     else:
         image = CustomFileModel()
         image.file.save(os.path.basename(new_file),
                         File(open(new_file, "rb")),
                         save=True)
         image.save()
     return image