lambda function for image detection

0

I would like to pass a image from a react web through cloud (lambda function) for image detection and return a json message of the detected result. But I have no idea how to send and recieve a message. How can I do that? Is it possible to de that without saving the image to a database?

asked a year ago222 views
2 Answers
1

For me it depends on the image file size.

If you retrieve small images (< 6 MB), you can go directly with the following:web client => API Gateway => Lambda (your image detection code) => API Gateway => web client. API Gateway will expose your Lambda function as a REST API.

If the images can be bigger, you will need to do it in 2-steps:

  1. Upload it to Amazon S3. You can do it directly from your client (for example using Amplify), or you can use pre-signed url. You can find a great article here. Return the pre-signed URL and a key (name of the S3 object) to the web client. The web client will use the URL to upload the file.
  2. Then you can do just like the first option (web client => API Gateway => Lambda (your image detection code) => API Gateway => web client) but instead of passing the file itself, you pass the key to the S3 object and your Lambda will have to retrieve it from S3 with the SDK.

Note that you will need to protect the S3 bucket and provide your users permissions to upload to it (using Cognito).

profile pictureAWS
answered a year ago
0

Hi there,

Can you provide a little more detail about your architecture?

It sounds like you have a React based web application, and you'd like to use it to send an image to Lambda for image processing. Are you already using an API Gateway to deliver the image payload to Lambda?

If all you are doing is some basic image processing, you can process the image within the Lambda function, and return the result as JSON to your React app via API Gateway. You would only need to use a database if you need to save the state/results of that image processing routine for use at another time.

profile pictureAWS
micah
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions