Explanation
This is an example of downloading a file that exists in a specific container in Microsoft Azure Blob Storage. DEXTUploadX5 provides the ability to download files from a container by obtaining a Shared Access Signature (SAS) token. To obtain a shared access token, you need to know the account, container, and access key information in advance, and the access key is sensitive information that should not be exposed to the outside world and must be handled in the backend.
The following code shows how to configure DEXTUploadX5 to download files from a container.
// Set up the AZRBS method.
dx.setDownloadMode("AZRBS");
dx.setAZRBSDownloadConfig({
accountName: "photomanager",
containerName: "photos",
// Handler address to generate the shared access token required for each step of the file downloading
sasDownloadURL: dx5.canonicalize("../service/get-download-sastoken.ashx")
});
sasDownloadURL is responsible for generating and returning the shared access token required when downloading files. To create the shared access token on the backend, we need to use the Azure SDK provided by Microsoft, which can be installed via NuGet for ASP.NET. In our sample project, we put the required Azure SDK binary files in the packages folder. For details on generating a shared access token using the Azure SDK, see the get-download-sastoken.ashx code.
The objects (files) stored in the container can be accessed with the following addressing scheme where ‘key’ is the same as the blob name.
https://{account-name}.blob.core.windows.net/{container-name}/{key}
We recommend that you set the above address to the URL of the virtual file.
dx.addVirtualFile({ name: "bridge_509147.jpg", size: 509147, url: "https://photomanager.blob.core.windows.net/photos/bridge_509147.jpg" });
dx.addVirtualFile({ name: "beach_239826.jpg", size: 239826, url: "https://photomanager.blob.core.windows.net/photos/beach_239826.jpg" });
dx.addVirtualFile({ name: "cosmos (empty) 195779.jpg", size: 195779, url: "https://photomanager.blob.core.windows.net/photos/cosmos+%28empty%29+195779.jpg" });
Example
Single-file download |
|
When the single-file downloading, the destination is not from the same source, so the browser may not download the destination and open it directly. |
|
Multiple-files download |
|
|