Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct way to escape an Azure Storage Blob Name

I am uploading files from a windows systems to Azure storage blobs

The local file names may contain characters that are invalid in blob names

I need a way of encoding these names as to fulfill the requirements set out by MSDN on blob storage names, as shown below

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.

The pertinent information above is "Reserved URL characters must be properly escaped. However, what method is the "standard" to use?

like image 588
TheGeneral Avatar asked Nov 10 '22 19:11

TheGeneral


1 Answers

You can use Uri.EscapeUriString(yourStringToEscape)

See docs here

You still have to do the other ones manually i.e the length and path segments .etc.

like image 126
Madushan Avatar answered Dec 27 '22 11:12

Madushan