Cod*_*nja 5 python django amazon-s3 amazon-web-services django-storage
我有两个文件字段的视频模型(存储在亚马逊 s3 中的媒体):
class Video(models.Model):
original = FileField(storage=S3BotoStorage())
small = FileField(storage=S3BotoStorage(), null=True)
Run Code Online (Sandbox Code Playgroud)
我只上传原始视频,然后上传后我在亚马逊弹性转码中创建转换作业(并且我为转换文件指定了文件路径)。
@receiver(post_save, sender=Video)
def handle_new_video(sender, instance, created, **kwargs):
if created:
send_transcode_job_request(instance.id, 'converted/file.mp4')
Run Code Online (Sandbox Code Playgroud)
作业完成后,我只想将文件路径保存到文件small字段。
@receiver(job_completed, sender=Video)
def handle_converting_completed(video_id, filepath, **kwargs):
video = Video.objects.get(id=video_id)
video.small.file.name = filepath
Run Code Online (Sandbox Code Playgroud)
如何在不重新上传视频的情况下执行此操作?
| 归档时间: |
|
| 查看次数: |
606 次 |
| 最近记录: |