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?

preguntada hace un año232 visualizaciones
2 Respuestas
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
respondido hace un año
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
respondido hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas