[英]Sending image file from http request in Node.js
我正在嘗試設置一個API,它將使用Google的照片參考ID作為參數從我的Google Places API返回圖像。 這是我到目前為止的內容:
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);
}
});
};
目前,郵件正文未以正確的格式發送。 有沒有一種方法可以將其另存為文件然后發送呢?
嘗試為投放圖片本身設置正確的標題:
res.set('Content-Type', 'image/gif');
在發送請求之前
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.