【发布时间】:2020-06-15 01:39:19
【问题描述】:
我正在尝试将文件上传到 azure blob 存储。我在后端收到它,但我一直收到错误 createBlobFromLocalFile should be a non-empty string 我正在接收文件,正如您在控制台输出中看到的那样,但我不明白为什么我不能将它发送到 blob 存储。我'已尝试将名为 blob string 的第二个参数替换为 req.file, req,file.path, req.file.destination + filename,但无法将其存储在 blob 中。感谢您的帮助!
app.js
app.post("/api/fileupload", checkAuth, upload, (req, res, next) => {
console.log("req.file below");
console.log(req.file);
blobService.createBlockBlobFromLocalFile('testcontainer', req.file, "image.png", function (error, result, response) {
console.log(response);
if (!error) {
// file uploaded
}
});
});
控制台输出
req.file below
{ fieldname: 'file',
originalname: 'blob',
encoding: '7bit',
mimetype: 'image/jpeg',
destination: 'public/uploads/',
filename: '18af517e9a94b2bdab02c7169b8b88a7',
path: 'public\\uploads\\18af517e9a94b2bdab02c7169b8b88a7',
size: 39367 }
TypeError: Parameter blob for function _createBlobFromLocalFile should be a non-empty string
【问题讨论】:
标签: node.js azure azure-blob-storage