简体   繁体   English

aws lambda:大尺寸图片上传和在PHP中调整大小

[英]aws lambda:Large sized image upload and resizing in php

We are planning to migrate one of our image uploading and resizing system into AWS cloud. 我们计划将我们的图片上传和调整大小系统之一迁移到AWS云中。

Proposed solution 提出的解决方案

1.User upload files into AWS s3. 1.用户将文件上传到AWS s3。

  1. S3 upload Invokes a lambda function in AWS lambda which will resize into a specified size(say 250*250) and put it into another s3 bucket. S3 upload在AWS lambda中调用lambda函数,该函数将调整为指定大小(例如250 * 250)并将其放入另一个s3存储桶中。

    we have an option that user can able to see the resized image and approve button. 我们有一个选项,用户可以看到调整大小的图像和批准按钮。

Since the upload image and resizing are two separate entities there is no way to identify image cropped is success or failed. 由于上传图像和调整大小是两个独立的实体,因此无法识别裁剪的图像是成功还是失败。

lambda function lambda函数

 function cropImage(objectKey){

    //do resize here 
    if(success){
      //need to the objectKey in the php function
     }

   }

So is there any way to communicate from the aws lambda function to php ?? 那么有没有办法从aws lambda函数到php进行通信?

There is an approach we use for our system. 我们的系统采用了一种方法。 Users upload their files through UI or an extension to our system. 用户通过UI或扩展名将文件上传到我们的系统。 The system handles the file and uploads it to S3. 系统处理文件并将其上传到S3。 After the file is uploaded the system calls to AWS Lambda, passing meta information, such as the API endpoint where to return the results. 上传文件后,系统调用AWS Lambda,传递元信息,例如API端点返回结果的位置。 We resize each image, collect the data and send a JSON back to the endpoint. 我们调整每个图像的大小,收集数据并将JSON发送回端点。 Of course it's a bit more complicated than just delegate whole work to AWS but it's a dynamic approach, that allows you to run your system from any server with a public IP. 当然,它比将整个工作委派给AWS要复杂得多,但它是一种动态方法,允许您从具有公共IP的任何服务器运行您的系统。

If there is just one server, why not keep the configs of the server right on Lambda. 如果只有一台服务器,为什么不在Lambda上保持服务器的配置。 There are Env vars available to set. 可以设置Env变量。 In this case you need either an endpoint or predetermined naming pattern for all resized images. 在这种情况下,您需要一个端点或预定的命名模式用于所有已调整大小的图像。

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

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