Django S3 file to InMemoryUploadedFile

There is a way to convert or use S3 file as a InMemoryUploadedFile :

For example i want to get my file from S3 using storage :

image = default_storage.open('example.png', 'r')

Then convert it to an InMemoryUploadedFile in order to use it in my Serializer :

image_temp = InMemoryUploadedFile(image, 'image_example', 'example.png', 'png', None, None)

Thanks.

Back to Top