Last active
December 23, 2015 21:19
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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