Is it possible, when calling ImageModel.save()
, to check if an image file has been uploaded?
For example:
- When creating the object, an image file should be uploaded in 99% of cases. If an image file is not uploaded, we may give an error or allow the user to create a placeholder object.
- When updating the object, the user may upload a new image file to replace it, or the user may upload no image file and only change a CharField in the object (and the previous image file remains).
save()
will be overridden to resize the uploaded image file using Pillow, compressed and optimized using mozjpeg, and finally saved to S3.
How can I check if an image file is being uploaded so that the Update cases can be accomodated?