Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: File upload to s3 using boto

I am trying to upload images (average size 12 MB) to my server (django using PIL)then I'm processing them to scale down images and creating thumbnails.

During this process I'm not saving images to server local disk instead, I'm using In Memory file and processing it. I'm uploading images to s3, using boto and I have original image, scaled image and the thumbnail which should be uploaded one by one (all these three are still present in my in Memory).

This process is very time consuming and sometimes the server which I am using (Digital Ocean 512 MB RAM) throws out of memory error.

Can I know is there any better way of uploading images

Any help is much appreciated. Thanks in advance.

like image 901
Govind Singh Avatar asked Mar 25 '17 07:03

Govind Singh


People also ask

How do I upload files to S3 bucket?

To upload folders and files to an S3 bucketSign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Buckets list, choose the name of the bucket that you want to upload your folders or files to. Choose Upload.


1 Answers

I haven't worked a lot with django & boto but u can try few suggestions:

  • Upgrade your server. if you are going to process that much big files, image processing requires a lot of memory.
  • You can try implementing queues (i.e. whenever you will get any upload request and file is bigger then enqueue it and process after current process is complete). You can use celery for this work.
  • If you don't need that much big files, then you can reduce image size at client side first and then pass it to the server.
like image 197
Shubhanu Sharma Avatar answered Oct 18 '22 19:10

Shubhanu Sharma