Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

627
Views
¿Cómo cambiar el tamaño de la imagen de S3 con Sharp?

Estoy tratando de cambiar el tamaño de la imagen cargada desde S3 usando @aws-sdk/v3 en la API de Node.js.

Primero, obtengo el objeto (imagen) de S3 como se muestra aquí: https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascriptv3/example_code/s3/src/s3_getobject.ts

 ... const params = { Bucket: AWS_BUCKET_NAME, Key: key } const data = await s3.send(new GetObjectCommand(params)) console.log(` >> Success, bucket returned:`, data) // Log correctly

Luego trato de cambiar el tamaño de los datos (imagen):

 const convert = sharp(data).resize(size, size).webp()

Pero arroja:

 >> data.type: object (node:35583) UnhandledPromiseRejectionWarning: Error: Input file is missing ...

Y no estoy seguro de cómo debo volver a cargarlo.

¿Qué estoy haciendo mal?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Creo que el constructor sharp acepta un búfer, pero lo que le estás pasando es la respuesta completa de la solicitud del SDK. En su lugar, intente pasar data.Body a sharp fn de esta manera:

const convert = sharp(data.Body).resize(size, size).webp();

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!