Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
Resizing images from AWS S3 with Node.js and Sharp

I am trying to create an endpoint on my API where I can resize images from S3 on-demand. I have got it working but it takes roughly 7s to return the resized image compared to roughly 800ms to return the image without resizing. I am new to manipulating images and decided to use the sharp package as it seemed quite simple to use. I was wondering if anyone could tell me if I am doing something wrong? Or a way to speed it up? Or is sharp just slow?

My code is:

const getCommand = new GetObjectCommand({
    Bucket: 'mybucket',
    Key: 'myfile'
});
const getResponse = await s3Client.send(getCommand);

// Set response headers
response.set('Content-Length', getResponse.ContentLength);
response.set('Content-Type', getResponse.ContentType);
response.statusCode = 200;

// Stream response
getResponse.Body.pipe(response);
// GetResponse.Body.pipe(sharp().resize(40, 40)).pipe(response)

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try to remove the Content-Length header:

response.set('Content-Length', getResponse.ContentLength);

When I tested your code this improved the performance.

Check if you observe the same improvement.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda