I would like to be able resize my uploaded image to various size categories:
- original
- medium (500kb)
- small (200kb)
And save it to AWS S3. And later be able to access it. One strategy is to save it in filename_small.jpg, filename_medium.jpg, have a helper function to be able to append the _small, _medium to access those files. Im not sure how to save all the different files (resized) and then access it with the helper.
https://gitlab.com/firdausmah/railercom/blob/master/railercomapp/storage_backends.py
class MediaStorage(S3Boto3Storage):
location = 'media'
file_overwrite = False
https://gitlab.com/firdausmah/railercom/blob/master/railercomapp/models.py
class Employee(models.Model):
...
face_image = models.FileField(upload_to=upload_to('employee/face_image/'), blank=True, storage=MediaStorage())
https://gitlab.com/firdausmah/railercom/blob/master/railercomapp/api.py
@api_view(['POST'])
def update_employee_image(request):
...
employee = Employee.objects.get(id = employee_id)
employee.face_image = face_image_obj
employee.save()
I am using django-storages and S3Boto3Storage. My full working project is in the git links.