嗨,我在请求中有此输入
{
"title": "Places Search Box",
"tags": "sd",
"pictures": {
"rawFile": {
"path": "Screenshot 2020-03-05 at 12.05.55 PM.png"
},
"banner": "blob:http://localhost:3001/3b3dead6-bee0-4a9c-a0b3-28a560ee1558"
}
}
我将如何使用node.js将这个Blob URL blob:http://localhost:3001/3b3dead6-bee0-4a9c-a0b3-28a560ee1558图像保存在文件夹中。
当我试图保存这样的内容时
const fs = require('fs');
const myUrl = res.pictures.banner;
fs.writeFile("/myFolder/myFile", myUrl, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
const fs = require('fs');
const res = {
"title": "Places Search Box",
"tags": "sd",
"pictures": {
"rawFile": {
"path": "Screenshot 2020-03-05 at 12.05.55 PM.png"
},
"banner": "blob:http://localhost:3001/3b3dead6-bee0-4a9c-a0b3-28a560ee1558"
}
}
const myUrl = res.pictures.banner;
fs.writeFile("/myFolder/myFile", myUrl, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
这很简单,如果您不明白,只问您错过了什么。