简体   繁体   English

直接上传后在s3上调整图像大小

[英]resizing image on s3 after direct upload

I'm trying to make the process of uploading images quicker on my first professional rails app and have started going in circles. 我正试图在我的第一个专业rails应用程序上更快地上传图像并开始进入圈子。 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. 我正在使用jquery直接上传直接上传到s3,从图像文件不接触服务器的角度来看,这会让事情变得更快。 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 ? 那些专家可以提出一个更好的方法,我可以在s3上处理我的图像,而不必将其复制回服务器或者在上传之前在jquery中调整它的大小吗?

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.. 我试着按照这篇文章使用延迟回形针和S3直接上传的答案,但它没有帮助,因为我收到很多错误..

Any suggestions or pointers would be helpful! 任何建议或指示都会有所帮助!

TIA!! TIA!

As John mentioned you could resize it via a Lambda function. 正如John所说,你可以通过Lambda函数调整它的大小。

Another option is to do the resizing at time of image fetching, ala a service like: 另一种选择是在图像获取时进行调整大小,例如:

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

Cloudinary - http://cloudinary.com/ Cloudinary - http://cloudinary.com/

You could trigger an AWS Lambda function when the picture is uploaded and process the image. 您可以在上传图片时触发AWS Lambda函数并处理图像。 This would require your code to be written in Node.js or Java, or at least be called from Lambda. 这将要求您的代码用Node.js或Java编写,或者至少从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) 以下是上传后自动调整图像大小的示例演练:AWS Lambda演练2:使用AWS CLI处理Amazon S3事件(Node.js)

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. 这个问题刚才被问过,但是我最近遇到过这个问题,我想分享一个非常直接的解决方案,我可以使用aws-lambda-image github项目来应用。 You basically clone the repository and install the npm dependencies , setup the reduce/resizes you want and you're ready to deploy . 您基本上克隆存储库并安装npm依赖项设置所需的reduce / resizes准备部署 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. 之后只需向S3存储桶添加触发事件 (您也可以通过AWS控制台上的S3 UI执行此操作 ,您的图像将在AWS / S3中处理。

I hope that can be helpful to others! 我希望这对别人有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM