简体   繁体   中英

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.

Proposed solution

1.User upload files into 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.

    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

 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 ??

There is an approach we use for our system. Users upload their files through UI or an extension to our system. The system handles the file and uploads it to 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. We resize each image, collect the data and send a JSON back to the endpoint. 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.

If there is just one server, why not keep the configs of the server right on Lambda. There are Env vars available to set. In this case you need either an endpoint or predetermined naming pattern for all resized images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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