Skip to content

Instantly share code, notes, and snippets.

@chrismatheson
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismatheson/9803536 to your computer and use it in GitHub Desktop.
Save chrismatheson/9803536 to your computer and use it in GitHub Desktop.
Azure deploy after refactor
function azureUpload(opts) {
var blobService = azure.createBlobService(),
containerName = opts.container;
console.log('setting container: ' + containerName);
blobService.createContainerIfNotExists(containerName, {publicAccessLevel : 'blob'}, function(error){
});
//create a writeable stream
var az = require('stream').Writable({objectMode: true});
az._write = function (chunk, enc, next) {
var filename = chunk.relative;
//Need better way of estalblishing if this is a file or dir
if(filename === '') {
next();
} else {
console.log('Uploading: ' + filename);
chunk.pipe(blobService.createBlob(containerName, filename, azure.Constants.BlobConstants.BlobTypes.BLOCK));
next();
}
};
return az;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment