【发布时间】:2015-09-09 01:23:22
【问题描述】:
我正在关注this article,了解如何将 blob 上传到容器中。这就是我所拥有的
var azure = require('azure-storage');
var blobSvc = azure.createBlobServiceAnonymous('https://<storage-name>.blob.core.windows.net/');
exports.post = function(request, response) {
console.log(request.files); // [1]
blobSvc.createBlockBlobFromLocalFile('dubfiles', 'myblob', request.files.file.name, function(error, result, response){
if(!error){
// file uploaded
console.log(response); //[2]
console.log(result); // [3]
}
});
};
[1] 记录这个
{ file:
{ domain: null,
_events: null,
_maxListeners: 10,
size: 859552,
path: 'D:\\local\\Temp\\155976e3a6b8e0aa871c5deee05af9f2',
name: 'heuristic-serch.pdf',
type: 'application/pdf',
hash: false,
lastModifiedDate: Tue Jun 23 2015 08:43:55 GMT+0000 (Coordinated Universal Time),
_writeStream: {
domain: null,
_events: null,
_maxListeners: 10,
path: 'D:\\local\\Temp\\155976e3a6b8e0aa871c5deee05af9f2',
fd: 3,
writable: false,
flags: 'w',
encoding: 'binary',
mode: 438,
bytesWritten: 859552,
busy: false,
_queue: [],
_open: [Function],
drainable: true,
flush: [Function],
write: [Function],
end: [Function],
destroy: [Function],
destroySoon: [Function],
pipe: [Function],
setMaxListeners: [Function],
emit: [Function],
addListener: [Function],
on: [Function],
once: [Function],
removeListener: [Function],
removeAllListeners: [Function],
listeners: [Function] },
open: [Function],
toJSON: [Function],
write: [Function],
end: [Function],
setMaxListeners: [Function],
emit: [Function],
addListener: [Function],
on: [Function], once: [Function],
removeListener: [Function],
removeAllListeners: [Function],
listeners: [Function]
}
}
[2] 记录对日志没有响应
[3] 没有结果记录到日志中
当我在 azure 管理门户上查看时,容器是空的。
如何正确地做到这一点?
【问题讨论】:
-
您的文件似乎没有保存在 Blob 存储中。请把
if(!error){改成if(error){看看有没有错误。 -
看起来您正在创建一个未经身份验证的存储客户端(匿名)。这不会阻止您创建容器和 blob 吗?
-
@GauravMantri 我把它改成了
if(error),我有这个错误-{ [Error: ENOENT, stat 'D:\home\site\wwwroot\heuristics-search.pdf'] errno: 34, code: 'ENOENT', path: 'D:\\home\\site\\wwwroot\\heuristics-search.pdf' } -
感谢您的帮助@GauravMantri
-
感谢您的帮助@DavidMakogon
标签: node.js azure azure-storage