Skip to content

Instantly share code, notes, and snippets.

@chechedotmx
Last active December 23, 2015 21:19
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 chechedotmx/6695312 to your computer and use it in GitHub Desktop.
Save chechedotmx/6695312 to your computer and use it in GitHub Desktop.
This codes retreives an existing blob URL with sas with permissions to write an Azure Blob, but this time using javascript from Node.js, working on Azure Mobile Services
var azure = require('azure');
var blobService = azure.createBlobService('storageAccountName', 'storageAccountKey', 'host');
blobService.createContainerIfNotExists(containerName, {
publicAccessLevel : 'blob'
}, function(error) {
if (error) {
console.log("Error : " + error);
}
});
var mins = 10;
var Constants = azure.Constants;
var BlobConstants = Constants.BlobConstants;
var startDate = new Date();
var expiryDate = new Date(startDate.getTime());
expiryDate.setMinutes(startDate.getMinutes() + mins);
var sharedAccessPolicy = {
AccessPolicy : {
Permissions : BlobConstants.SharedAccessPermissions.WRITE,
Start : startDate,
Expiry : expiryDate
}
};
var signature = blobService.generateSharedAccessSignature(containerName, blobName, sharedAccessPolicy);
var urlSignature = signature.url();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment