.net - 转义 Azure 存储 Blob 名称的正确方法

标签 .net azure azure-functions azure-blob-storage

我正在将文件从 Windows 系统上传到 Azure 存储 blob

本地文件名可能包含 Blob 名称中无效的字符

我需要一种对这些名称进行编码的方法,以满足 MSDN 对 Blob 存储名称提出的要求,如下所示

A blob name must conforming to the following naming rules:

  • 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.

上面的相关信息是“保留的URL字符必须正确转义。但是,使用什么方法是“标准”的?

最佳答案

您可以使用Uri.EscapeUriString(yourStringToEscape)

参见docs here

您仍然需要手动执行其他操作,即长度和路径段等。

关于.net - 转义 Azure 存储 Blob 名称的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28143759/

相关文章:

.net - 如何使用特定值快速填充数组?

azure - 如何使用 Application Insights 在将新资源添加到资源组时创建警报

c# - Visual Studio 中的 Azure Functions - 如何添加对另一个项目的引用

windows - 在计算模拟器下启动 Azure Web 角色时出现 "No endpoint listening"

c# - Azure 函数获取登录标识

azure-functions - OpenApiExample 未显示在 swagger UI 中

azure - 如何让某些代码仅在Azure函数第一次运行时运行?

c# - 求解具有约束结果的最小二乘矩阵

.Net Web 引用 SSL 错误

C# GZipStream - 压缩 MemoryStreams