none
Problems writing in a blobstorage from a virtual machine

    Question

  • Hello everyone,

    I'm uploading images to a blob storage container using nodejs.

    the following script:

    var fs = require('fs');
    var azure = require('azure');
    var Stream = require('stream');
    var mmm = require('mmmagic'),
    	Magic = mmm.Magic;
    
    var blobConfig = {
    	storageAccount: "<your storage account>",
    	storageAccessKey: "<yourKey>"
    };
    
    var blobService = azure.createBlobService(blobConfig.storageAccount, blobConfig.storageAccessKey);
    
    
    var base64Image = "<your base64 encoded image>";
    var decodedImage = new Buffer(base64Image, 'base64');
    
    
    var magic = new Magic(mmm.MAGIC_MIME_TYPE);
    
    magic.detect(decodedImage, function(err, result) {
    	if(err) {
    		throw err;
    	}
    
    	var bytes = 0;
    	var imageStream = new Stream();
    	imageStream.writable = true;
    
    	imageStream.write = function(buf) {
    		bytes += buf.length;
    		imageStream.emit('data', buf);
    	};
    
    	imageStream.end = function(buf) {
    		if(arguments.length) {
    			imageStream.write(buf);
    		}
    
    		imageStream.writable = false;
    		imageStream.emit('end');
    		console.log(bytes + ' bytes written');
    	};
    
    	var options = {}
    	console.log(result);
    	options.contentType = result;
    	options.contentTypeHeader = result;
    
    	blobService.createBlockBlobFromStream('images', 'image_decoded.jpg', imageStream, decodedImage.length, options, function(result) {
    		console.log(result);
    	});
    
    	imageStream.end(decodedImage);
    });

    now: this works perfectly from my machine, quickly uploading the image.

    When I push the script in an ubuntu virtual machine I get a 

    { [Error: socket hang up] code: 'ECONNRESET' }

    error while uploading the image :(

    I can't understand why this is happening, any suggestion?

    thx for help

    regards

    lucio


    Thursday, December 13, 2012 4:41 PM

Answers

All replies