0
votes

I am using @azure/storage-blob, i am able to upload file, but how do i retrieve it? any ideas how to get SAS url of storage?

i need to generate url which expires in few minutes, and url is token based, because container is not for public access. kindly help in node.js or guide me with some plugin which helps to get/generate sas url for that file in blob storage. Thank you in advance!

1

1 Answers

5
votes

To generate a Shared Access Signature (SAS URL) on a blob, you can use generateBlobSASQueryParameters function available in the SDK.

const blobSAS = generateBlobSASQueryParameters({
    containerName, // Required
    blobName, // Required
    permissions: BlobSASPermissions.parse("r"), // Required
    startsOn: new Date(), // Required
    expiresOn: new Date(new Date().valueOf() + 86400) // Optional. Date type
   },
  sharedKeyCredential // StorageSharedKeyCredential - `new StorageSharedKeyCredential(account, accountKey)`
).toString();