[BUG] BlobUriBuilder URL encodes slashes in blob names
See original GitHub issueDescribe the bug When working with blobs with slashes in the name the slashes get URL encoded by BlobUriBuilder which makes the URLs parse incorrectly later when trying to extract path segments.
Expected behavior Slashes should not be encoded by BlobUriBuilder.
var container = blobClient.GetBlobContainerClient("animals");
var blob = container.GetBlobClient("mammals/cat.png");
var blobUri = blob.Uri;
blobUri == "https://storageaccount.blob.core.windows.net/animals/mammals/cat.png"
Actual behavior (include Exception or Stack Trace) Slashes are encoded by BlobUriBuilder
blobUri == "https://storageaccount.blob.core.windows.net/animals/mammals%2fcat.png"
To Reproduce See expected behavior.
Environment:
- Name and version of the Library package used: <PackageReference Include="Azure.Storage.Blobs" Version="12.6.0" />
- Hosting platform or OS and .NET runtime version (
dotnet --info
output for .NET Core projects): Windows 10 .NET Core App - IDE and version : Visual Studio 16.8.0 preview 2
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Upgrading Azure Blob API 11->12, leading slash in ...
One possible workaround is to create an instance of BlobClient using the full URL of the blob. That way the leading slashes are...
Read more >I can't get Azure Storage to support putting data from URLs ...
I can't get Azure Storage to support putting data from URLs that need "%2F" verbatim in them into blobs.
Read more >the 'Cannot find the blob when DownloadToStream. Uri ...
If the blob name or container name contains special characters or spaces, ensure that they are URL-encoded properly. Failing to encode the names...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is by design, the service considers
mammals/cat.png
andmammals%2fcat.png
to be the same blob. I recommend using theName
property instead ofUri
if you would like to later extract path segments.@mgroetan The change is intentional and was part of larger internal refactoring. Service doesn’t distinguish
/
from%2f
but considering multiple asks to not encode/
we decided to change it. As @seanmcc-msft mentioned we recommend to useBlobName
rather thanUri
for parsing purposes.