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

522
Views
Enviando un archivo de imagen desde una solicitud http en Node.js

Estoy tratando de configurar una API que devolverá una imagen de mi API de Google Places usando la ID de referencia de la foto de Google como parámetro. Esto es lo que tengo hasta ahora:

 module.exports.getPhoto=function(req,res){ var id=req.params.id; var url='https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference='+id+'&key='+process.env.GOOGLEAPI; request.get(url, function (err,response,body) { if(err){ res.status(400).json(err); }else{ res.send(body); } }); };

En este momento, el cuerpo no se envía en el formato correcto. ¿Hay alguna manera de hacer esto sin guardarlo como un archivo y luego enviarlo?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Intente configurar los encabezados correctos para servir la imagen en sí:

 res.set('Content-Type', 'image/gif');

antes de enviar una solicitud

about 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!