Friendly filename when public download Azure blob

CeejeeB picture CeejeeB · Aug 11, 2011 · Viewed 12.5k times · Source

Is it possible to save a blob with a name of a GUID (or anything else) but when a user requests the files URI http://me.blob.core.windows.net/mycontainer/9BB34783-8F06-466D-AC20-37A03E504E3F the download comes down with a friendly name e.g. MyText.txt?

Answer

alek kowalczyk picture alek kowalczyk · Jun 10, 2015

Now it is possible by setting the content-disposition header on generating the Shared Access Signature:

  string sasBlobToken = blob.GetSharedAccessSignature(sharedPolicy, new SharedAccessBlobHeaders()
            {
                ContentDisposition = "attachment; filename=" + friendlyFileName
            });
  string downloadLink = blob.Uri + sasBlobToken;