none
How do I set a header for my hosted files in Azure Blob Storage?

    Question

  • I am trying to use Azure Blob Storage as an option for self-hosting with the Sendowl ecommerce system on my website. I have the URL from the hosted file right here as an example: https://blipsoundsstorage.blob.core.windows.net/blipsoundslibraries/Blood%20and%20Bones%20Demo%2001.mp3

    My goal is to be able to open up the link and have it download from the browser automatically rather than play the file in the browser. Sendowl support told me that I need to add a header to the file and showed me this in the documentation

    <section class="callout-yellow" style="box-sizing:border-box;background:rgb(255, 252, 213);border-left:5px solid rgb(231, 220, 164);color:#333333;font-size:15px;margin-bottom:2em;padding:12px 25px 2px 20px;font-family:Lato, proxima-nova, 'Helvetica Neue', Arial, sans-serif;">

    Important Configuration Notes

    Note that if the buyer's browser recognizes the file type (such as a PDF), it will default to displaying the file in the browser window.

    To force the browser to download the file instead of displaying it, you will need to set the headers for each self-hosted file to:

    “Content-Disposition” “attachment"

    Setting the header as above also ensures the 'Download All' button works as expected when selling the multiple files.

    </section>

    How would I set the blob-hosted files to download the file instead of displaying it? Thank you. I appreciate the help.

    -Ryan

    Tuesday, October 11, 2016 4:54 PM

All replies

  • Ryan,

    you would need to set the blob metadata (in particular its ContentDisposition property) - refer to https://www.simple-talk.com/cloud/platform-as-a-service/azure-blob-storage-part-6-blob-properties-metadata-etc/

    hth
    Marcin

    Tuesday, October 11, 2016 5:18 PM
  • So I would just put ContentDisposition into the metadata of my desired file? What goes into both of the following text areas?

    It still isn't quite clear what exactly I need to do. Thanks!

    Tuesday, October 11, 2016 5:50 PM
  • That would depend on what interface you are looking at... ;)

    Here is how you'd do this via PowerShell

    https://robindotnet.wordpress.com/2015/07/13/accessing-properties-of-azure-blobs-with-powershell/

    hth
    Marcin

    Tuesday, October 11, 2016 6:08 PM
  • I'm doing this with Microsoft Azure Storage Explorer! Is it possible to do it with this? Or do I need to use CLI with my computers terminal?
    Tuesday, October 11, 2016 6:16 PM
  • I don't believe Storage Explorer exposes this property. Use the link I referenced earlier for PowerShell or try an equivalent commands via CLI

    hth
    Marcin

    • Marked as answer by Ryan Stunks Tuesday, October 11, 2016 8:02 PM
    • Unmarked as answer by Ryan Stunks Tuesday, October 11, 2016 9:15 PM
    • Marked as answer by Ryan Stunks Wednesday, October 12, 2016 1:03 AM
    • Unmarked as answer by Ryan Stunks Wednesday, October 12, 2016 5:41 PM
    Tuesday, October 11, 2016 7:53 PM
  • Okay awesome. Thanks so much!
    Tuesday, October 11, 2016 8:02 PM
  • Question. I'm using powershell right now and I keep on getting an error for my commands. I'll put in a command and get a response like t

    PS C:\> Get-AzureRmResource Get-AzureRmResource : The term 'Get-AzureRmResource' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Get-AzureRmResource + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (get-azurermresourcefork:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

    I found that you can fix this with a guide online. It says this:

    "This can be corrected by restarting the machine or importing the cmdlets from C:\Program Files\WindowsPowerShell\Modules\Azure\XXXX\ as following (where XXXX is the version of PowerShell installed: import-module "C:\Program Files\WindowsPowerShell\Modules\Azure\XXXX\azure.psd1" import-module "C:\Program Files\WindowsPowerShell\Modules\Azure\XXXX\expressroute\expressroute.psd1""

    I am on Mac currently doing this... and I'm not sure what the above solution means. Is this even the correct solution? Any help would be great. Thanks!

    Tuesday, October 11, 2016 9:43 PM
  • You will not be able to run PowerShell on Mac - at least not directly. Spin a Windows Server 2012 R2 VM in Azure, download Azure PowerShell from https://github.com/Azure/azure-powershell/releases and you should be good to go...

    hth
    Marcin

    Tuesday, October 11, 2016 10:16 PM
  • Okay thanks. I've been messing around with powershell... it seems very complicated. Is there an easier way to achieve what I want to do? I need to do this to a lot of files on my Blob Storage and if there is a quicker way to do it, that'd be great.
    Wednesday, October 12, 2016 5:42 PM