m00nbeam360
m00nbeam360

Reputation: 1377

Upload blobs with metadata, node

How would I go about uploading blob metadata into Azure in Node? I have:

blobService.createBlockBlobFromText(containerName, function(error) { 
    //what would go in here? 
});

I see that there is a link to set blob metadata, but I can't really interpret what it means.

Does anyone know if it's possible to set blob metadata in Node?

Upvotes: 2

Views: 3182

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136206

Try this code. This creates a blob in a blob container using createBlockBlobFromText method and sets two metadata items with the 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);

        }
    });
} 

Upvotes: 4

Related Questions