I want to retrieve the binary data of an image from a Microsoft Azure blob storage container.
I have successfully uploaded an image to a storage container on Azure from an iOS app using the following function on AZSCloudBlobContainer.
blockBlob.uploadFromData(imageData, completionHandler:
I can also successfully download it straight to the iOS app using the following function on AZSCloudBlob.
blockBlob.downloadToDataWithCompletionHandler({(error: NSError?, data: NSData?)
The problem I have is that I want to be able to retrieve the image from a node.js server side script, not directly from the app. Amongst others, I have tried the following code...
var containerName = 'containerName';
var blobService = storage.createBlobService(accountName, accountKey);
var blobName = 'blobname';
var fs = require('fs');
var stream = fs.createWriteStream('output.txt');
blobService.getBlobToStream(containerName, blobName, stream, function (error, result, response2) {
response.json(result);
});
The response retrieves the blob information but I don't know how to get the actual binary data of the image?
({
blobType = BlockBlob;
container = containername;
contentLength = 14593;
contentSettings = {
contentType = "application/octet-stream";
};
etag = "\"0x8D********\"";
lastModified = "Mon, 05 Sep 2016 18:57:41 GMT";
lease = {
state = available;
status = unlocked;
};
metadata = {
};
name = "blobname";
requestId = "ce3e7************";
serverEncrypted = false;
})
I've tried many other avenues as well but I'm completely new to node.js and have spent far too much time trying to solve this, any direction would be much appreciated, thanks.