azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

BlobUriBuilder preserve slashes

Open jaschrep-msft opened this issue 3 years ago • 2 comments

Addresses #24955

BlobUriBuilder strips leading and trailing slashes from blob names when constructing the Uri. Creating a client to a blob with a leading or trailing slash in blob name requires invoking the constructor directly (BlobClient(Uri, Credential, BlobClientOptions), which forces a developer to keep references to their credentials wherever they may need to create a blob client. While this and other modern Storage libraries make it very difficult to create a blob with a trailing slash in the name, it is still possible. Additionally, other libraries for interacting with Storage may be creating blobs with this behavior. Clients should be capable of accessing these blobs in our recommended workflows.

Changes:

  • BlobUriBuilder has an additional constructor which takes a flag on whether to preserve leading and trailing slashes on blob name.
  • BlobUriBuilder has a static bool property PreserveOuterSlashesDefault determining what default value the original constructor will use. Default is false.

Static property was created to avoid overloading BlobContainerClient.GetBlobClient() and similar methods. A developer upgrading behavior, instead of needing to edit every call to GetBlobClient(), now just needs to set this hook.

This default flag was considered for an instance property on BlobClientOptions instead. Rejected idea because it did not feel like a configuration on client behavior, but rather library behavior in general.

jaschrep-msft avatar Aug 02 '22 17:08 jaschrep-msft

API change check

APIView has identified API level changes in this PR and created following API reviews.

Azure.Storage.Blobs

azure-sdk avatar Aug 02 '22 17:08 azure-sdk

"Do Not Merge" added as this PR contains API changes and the upcoming release has already gone through API review. Must wait for next one.

jaschrep-msft avatar Aug 09 '22 21:08 jaschrep-msft