如何将s3中存在的文件保存到Django filefield

2024-09-28 05:36:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我有两个文件字段的视频模型(存储在amazon s3中的媒体):

class Video(models.Model):
    original = FileField(storage=S3BotoStorage())
    small = FileField(storage=S3BotoStorage(), null=True)

我只上传原始视频,上传后我在amazon弹性转码中创建转换作业(并为转换后的文件指定了文件路径)。在

^{pr2}$

作业完成后,我只想将文件路径保存到smallfilefield。在

@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

如何在不重新上传视频的情况下做到这一点?在


Tags: 文件模型路径idamazon视频video作业

热门问题