如何将blob元数据上传到Node中的Azure?我有:
blobService.createBlockBlobFromText(containerName, function(error) {
//what would go in here?
});
我看到有link来设置blob元数据,但我无法解释它的含义。
有人知道是否可以在Node中设置blob元数据?
答案 0 :(得分:2)
试试这段代码。这将使用createBlockBlobFromText
方法在blob容器中创建blob,并使用blob设置两个元数据项:
var AZURE = require('azure');
TestBlobUpload('testcontainer');
function TestBlobUpload(ContainerName)
{
var blobService = AZURE.createBlobService('UseDevelopmentStorage=true'); // error occurred at this line
blobService.createContainerIfNotExists(ContainerName, {publicAccessLevel : 'blob'}, function(error){
if(!error)
{
console.log("Container created successfully.");
blobService.createBlockBlobFromText(ContainerName, 'simplefile.txt', 'Sample content', {
metadata: {
'a': 'a',
'b': 'b',
}}, function(error){
if(!error) {
console.log("Blob created from Text successfully.");
} else {
console.log("error: "+error);
}
});
}
else
{
console.log("error: "+error);
}
});
}