I have a worker that takes in a video and generates a thumbnail of that video. The worker then uploads the thumbnail to S3.
What I want to do is upon completion hit a TastyPie resource and save the path that the image was uploaded to. But I'm having trouble because TastyPie is expecting a File to be sent and I'm sending just the path.
Is there a way to fake upload this file?
class Video(models.Model):
thumbnail = models.ImageField(blank=True, null=True)
class VideoResource(NamespacedModelResource):
thumbnail = fields.FileField(null=True, blank=True)
def hydrate_thumbnail(self, bundle):
# The following is obviously wrong.
# bundle.data['thumbnail'] is set to the path that the image is already stored
from django.core.files import File
return File(bundle.data['thumbnail'])