0

There is html code written for download button. The complete Sharepoint 2013 hosted application functionality has JS code.
There is WCF solution using C# to get data from SAP system.
There is one page in application which has download button. Once clicked by the user, the file should get downloaded from Azure blob storage.

Kindly help how we can achieve this.

Ryan M
  • 18,333
  • 31
  • 67
  • 74
Anjali
  • 13
  • 3
  • Check this https://stackoverflow.com/questions/18605910/azure-blob-file-download-link – Rimander Oct 22 '21 at 09:30
  • Please edit your question and include the code you have written so far and the issues you're running into. From your question it looks like someone has given you a coding exercise and you are looking for a readymade solution to that. – Gaurav Mantri Oct 22 '21 at 09:32
  • @GauravMantri : There are pdf files stored as Azure blob storage. We do have sharepoint 2013 portal whose UI functionality is built in JS. Already there is solution built in C# as wcf service to get data from SAP system to sharepoint. However I need a guidance on how can I achieve downloading these pdf from bowser . Kindly assist since i have not worked before on azure – Anjali Oct 25 '21 at 06:58

1 Answers1

0

I have tested in my environment

You can use the below javascript function to download files from Azure blob storage :

    async function main() {
        var fs = require('fs');
        const { BlobServiceClient, StorageSharedKeyCredential } = require("@azure/storage-blob");
        const account = "storage account name";
        const accountKey = "storage account key"
        const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey);
        const blobServiceClient = new BlobServiceClient(
        `https://${account}.blob.core.windows.net`,
        sharedKeyCredential);
        const containerClient = blobServiceClient.getContainerClient("container name");
        const blobClient = containerClient.getBlobClient("blob file name to be downloaded");
        const response = await blobClient.downloadToFile("blob file name to be downloaded");
    main();
RamaraoAdapa
  • 2,837
  • 2
  • 5
  • 11
  • There are pdf files stored as Azure blob storage. We do have sharepoint 2013 portal whose UI functionality is built in JS. Already there is solution built in C# as wcf service to get data from SAP system to sharepoint. However I need a guidance on how can I achieve downloading these pdf from bowser . Kindly assist since i have not worked before on azure – Anjali Oct 25 '21 at 06:59
  • When the user clicks download button on the UI, the pdf file stored in Azure blob storage needs to be downloaded. Is this your requirement? – RamaraoAdapa Oct 25 '21 at 07:19
  • Yes. This is the requirement – Anjali Oct 25 '21 at 07:58
  • But there will be azure connection required, right? Also Azure REST API call to get the blobs? – Anjali Oct 25 '21 at 08:33
  • I have edited the answer. You can use the above javascript function to download the blob files from a storage account – RamaraoAdapa Oct 25 '21 at 13:16