我跟随this article如何将blob上传到容器中。这是我一直有天青blob存储node.js后端
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]日志中没有结果记录
当我检查天蓝色的管理门户时,容器是空的。
这怎么能正确完成?
看起来像你的文件没有被保存在blob存储。请将'if(!error){'改为'if(error){'并查看是否有错误。 –
看起来喜欢你正在创建一个未经过身份验证的存储客户端(匿名)。这不妨碍您创建容器和Blob吗? –
@GauravMantri我把它改成了'if(error)',我有这个错误 - '{[Error:ENOENT,stat'D:\ home \ site \ wwwroot \ heuristics-search.pdf'] errno:34,code: 'ENOENT',路径:'D:\\ home \\ site \\ wwwroot \\ heuristics-search.pdf'}' –