我已将 pdf 文件保存在 azure blob 存储 blob 中,我想在我的网站上显示这些文件,但是当文件在 html 上呈现时,其链接应被停用,这意味着没有人可以使用该链接再次下载该文件。这在 azure 的 blob 存储中可能吗?
最佳答案
您可以使用 blob 策略来实现:
CloudStorageAccount account = CloudStorageAccount.Parse("yourStringConnection");
CloudBlobClient serviceClient = account.CreateCloudBlobClient();
var container = serviceClient.GetContainerReference("yourContainerName");
container
.CreateIfNotExistsAsync()
.Wait();
CloudBlockBlob blob = container.GetBlockBlobReference("test/helloworld.txt");
blob.UploadTextAsync("Hello, World!").Wait();
SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy();
// define the expiration time
policy.SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(1);
// define the permission
policy.Permissions = SharedAccessBlobPermissions.Read;
// create signature
string signature = blob.GetSharedAccessSignature(policy);
// get full temporary uri
Console.WriteLine(blob.Uri + signature);
关于Azure Blob 存储临时文件 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61320076/