我正在尝试通过Blob容器网址+ SAS下载Azure Blob文件。
public string GenereteDownloadLinkForBlob(CloudBlob blob)
{
var storageAccount = CloudStorageAccount.Parse(_config.StorageConnectionString);
// Create a new access policy for the account.
var policy = new SharedAccessBlobPolicy
{
Permissions = SharedAccessBlobPermissions.Read,
SharedAccessStartTime = DateTime.UtcNow.AddHours(-_config.SasLifetime),
SharedAccessExpiryTime = DateTime.UtcNow.AddHours(_config.SasLifetime),
};
var sasBlobToken = blob.GetSharedAccessSignature(policy);
return blob.Uri + sasBlobToken;
}
获取网址后,我尝试通过带有标签href的生成的url下载该文件,但我重定向到了azure blob文件。
<a href="@file.DownloadUrl" download="@file.FileName" class="btn btn-success">Download</a>
DownloadUrl-在这种情况下,它是Blob uri + sas。是否可以通过此链接从azure下载文件?