4

I'm trying to make the process of uploading images quicker on my first professional rails app and have started going in circles. I'm using jquery direct upload to upload directly to s3 which makes things quicker from the point of view that the image file doesn't touches the server. However, when I try to process the file using delayed paperclip and delayed job, the file is copied back to the server for processing - which I wanted to avoid at the first place.

Could the experts out there suggest a better way by which I can process my image on s3 itself without having to copy it back to sever or perhaps resize it in jquery before uploading ?

I tried to follow the answer in this post Using Delayed Paperclip With S3 Direct Upload , but it did not help as I get lots of errors..

Any suggestions or pointers would be helpful!

TIA!!

Community
  • 1
  • 1
pari
  • 145
  • 1
  • 14

3 Answers3

3

As John mentioned you could resize it via a Lambda function.

Another option is to do the resizing at time of image fetching, ala a service like:

Imgix - https://www.imgix.com/

Cloudinary - http://cloudinary.com/

Cody Caughlan
  • 32,456
  • 5
  • 63
  • 68
2

You could trigger an AWS Lambda function when the picture is uploaded and process the image. This would require your code to be written in Node.js or Java, or at least be called from Lambda.

Here is a sample walkthrough that resizes an image automatically after upload: AWS Lambda Walkthrough 2: Handling Amazon S3 Events Using the AWS CLI (Node.js)

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Thanks for the replies. Image processing is a science in itself. I think I'll stick with DJ, paperclip and jquery for the time being. I'm not sure if its just me (as i'm growing old), but aws documentation seems to quite cryptic much like MS doco without any examples. – pari Aug 25 '15 at 03:36
0

This question has been asked a while ago but as I've faced this recently, I'd like to share a pretty straight forward solution I was able to apply using aws-lambda-image github project. You basically clone the repository and install the npm dependencies, setup the reduce/resizes you want and you're ready to deploy. After that just add a triggering event to your S3 bucket (you can also do it via the S3 UI on AWS Console and your images will be processed within AWS/S3.

I hope that can be helpful to others!

fagiani
  • 2,293
  • 2
  • 24
  • 31