gpt4 book ai didi

azure - 使用GetBlockBlobReference()时如何避免字符隐藏?

转载 作者:行者123 更新时间:2023-12-03 01:05:11 24 4
gpt4 key购买 nike

当我使用 Microsoft Azure 的云 block Blob 的方法 GetBlockBlobReference() 时,我发现它将一些字符(例如 # )转换为 %23。这不是我想要的。我怎样才能避免这种情况?代码段如下:

string pvtFileName = "pvt/" + fileName.Replace(StlFilePostfix, PvtFilePostfix);//the name contains #
BlobRequestOptions bl = new BlobRequestOptions();
bl.RetryPolicy = new LinearRetry(TimeSpan.FromSeconds(50), 6);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
var blobContainerPVT = blobClient.GetContainerReference(smodContainer.ToLower());
blobContainerPVT.CreateIfNotExists();
try
{
CloudBlockBlob pvtBlob = blobContainerPVT.GetBlockBlobReference(pvtFileName);
using (var fileStream = File.OpenRead(fileFullPath.Replace(StlFilePostfix, PvtFilePostfix)))
{
pvtBlob.UploadFromStream(fileStream, null, bl);
}} catch (Exception e)
{
Trace.TraceInformation(e.Message);
}

无论我是否使用 HttpUtility.UrlEncode() 格式化文件名,该方法都会将 # 转换为 %23

最佳答案

Blob 名称必须符合以下命名规则:

A blob name can contain any combination of characters.

A blob name must be at least one character long and cannot be more than 1,024 characters long.

Blob names are case-sensitive.

Reserved URL characters must be properly escaped.

The number of path segments comprising the blob name cannot exceed 254. A path segment is the string between consecutive delimiter characters (e.g., the forward slash '/') that corresponds to the name of a virtual directory.

enter image description here

URI 的区别仅在于是否为 reserved character is percent-encoded或 按字面意思出现的字符通常被认为是不等价的(表示相同的资源),除非可以确定所讨论的保留字符没有保留目的。

这里是A Complete Guide to URL Escape Characters .

关于azure - 使用GetBlockBlobReference()时如何避免字符隐藏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50575470/

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