I have django 1.11 with latest django-storages, setup with S3 backend.
I am trying to programatically instantiate an ImageFile, using the AWS image link as a starting point. I cannot figure out how to do this looking at the source / documentation.
I assume I need to create a file, and give it the path derived from the url without the domain, but I can't find exactly how.
The final aim of this is to programatically create wagtail Image
objects, that point to S3 images (So pass the new ImageFile to the Imagefield of the image). I own the S3 bucket the images are stored in it.
Uploading images works correctly, so the system is setup correctly.
Update
To clarify, I need to do the reverse of the normal process. Normally a physical image is given to the system, which then creates a ImageFile
, the file is then uploaded to S3, and a URL is assigned to the File.url
. I have the File.url
and need an ImageFile
object.
my_model.upload = "s3 object key.jpg"
instead ofmy_model.upload.save(...)
– Metallurgy