question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] BlobUriBuilder URL encodes slashes in blob names

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
seanmcc-msftcommented, Sep 14, 2020

This is by design, the service considers mammals/cat.png and mammals%2fcat.png to be the same blob. I recommend using the Name property instead of Uri if you would like to later extract path segments.

1reaction
kasobol-msftcommented, Jun 24, 2021

@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 use BlobName rather than Uri for parsing purposes.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found