gpt4 book ai didi

Azure Blob 存储临时文件 URL

转载 作者:行者123 更新时间:2023-12-02 05:56:37 24 4
gpt4 key购买 nike

我已将 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com