【发布时间】:2020-04-14 20:53:13
【问题描述】:
我是节点新手。我一直在挖掘试图找出如何路由我从谷歌驱动器 api 获得的传入图像。我试过下载它,但它需要很长时间。我希望能够在收到后立即将其发送给客户。这可能很简单,但我想做的就是将它保存到 png 文件中。 .蚂蚁帮助将不胜感激。
app.get("/img", function(req,res){
https.get(url,function(resp){
console.log(resp.statusCode);
console.log(resp.headers['content-type']);
resp.on("data", function(chunk){
// I am getting the image raw data
.pipe(fs.createWriteStream("public/images/test.png"));
【问题讨论】:
-
那么问题出在哪里?你的代码看起来不错?
-
我收到此错误。 .pipe(fs.createWriteStream("public/images/test.png")); ^ SyntaxError: Unexpected token .
标签: javascript node.js express image-processing google-drive-api