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.

How to generate a non-SAS uri with custom Content-disposition in a public access container

See original GitHub issue

Library name and version

Azure.Storage.Blobs 12.10.0

Query/Question

Lets say we have a public container in which we store files where each blob is a file. Because we don’t want to prompt the user every time they collide with another user’s filename then we store the stream of data under a generated GUID BlobName and not the actual filename. We however upload the file with a custom content-disposition so that the user will be able to recognize his or her file when downloading it.

var blobClient = _containerClient.GetBlobClient(blobName);
var blobUploadOptions = new BlobUploadOptions()
{
   HttpHeaders = new BlobHttpHeaders() { ContentDisposition = "attachment; filename=\"" + $"{blobName}.{extension}" + "\"; filename*=UTF-8''" + Uri.EscapeDataString($"{fileName}.{extension}") }
};

await blobClient.UploadAsync(stream, blobUploadOptions);

Since we don’t want our system to be the middle- man of downloading the file and then passing it on to the user then we want to construct a Uri with direct access to the blob in Azure blob storage and respects the custom content-disposition. This URI we then pass on to the user.

However, using the Uri property of the BlobClient won’t respect the custom content-disposition.

var blobClient = _containerClient.GetBlobClient(blobName);
return blobClient.Uri.ToString();

This is odd though because retrieving the custom content-disposition after it has been uploaded yields the correct result. image As you can see in this picture the custom content-disposition is known to Azure blob storage but why is it not getting respected then?

Is there really not a way to generate a non-SAS uri that will respect the custom content-disposition?

We have had success generating SAS Uris respecting the custom content-disposition in the past but in this case where the container is of blob public access type then generating shared access tokens is not what we want.

Environment

.NET 6

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
SatishBoddu-MSFTcommented, Feb 9, 2022

Hello @Brutiquzz Thanks for the query. We are routing this to the Service team to address the question.

1reaction
karol-grocommented, Jun 19, 2023

Is there any update on this? Apparently, it’s a property of the blobs which has been there for years and no documentation mentions it (see https://stackoverflow.com/questions/54207583/azure-blob-storage-v2-does-not-deliver-content-disposition-header-any-more )

So, is this the result of some decision (if so, why is this and will this be documented? Or is it a defect in Azure Blob Storage (if so, when can we expect it to be fixed)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set content disposition on individual azure blob ...
When you want to selectively apply this property on a blob (say on a per request basis), what you do is create a...
Read more >
Configure anonymous public read access for containers ...
Learn how to allow or disallow anonymous access to blob data for the storage account. Set the container public access setting to make...
Read more >
Direct download from Azure Blob storage using Content ...
I have set the container to be a public one, and by generating random file names, I have some obfuscation so that iterating...
Read more >
Content-Disposition - HTTP - MDN Web Docs
The first parameter in the HTTP context is either inline (default value, indicating it can be displayed inside the Web page, or as...
Read more >
Content Disposition Values and Parameters
Content Disposition Values ; inline, displayed automatically, (none) ; attachment, user controlled display, filename, creation-date, modification- ...
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