Download anchor link with authorization header

后端 未结 1 1460
鱼传尺愫
鱼传尺愫 2021-02-11 18:26

I have a link that I would like to add to my javascript (Marionette/Backbone) single page application that will download an Excel file to the user\'s local drive via the browser

相关标签:
1条回答
  • 2021-02-11 19:05

    This not possible, because the only way to add HTTP headers is using the XHR, but XHR cannot be used to download files.

    You could however use cookies to do that.

    1. Just set the cookie, with a returned value from the server.
    2. Wait till the user clicks the link.
    3. Invalidate the cookie after the user clicked the link.
    0 讨论(0)
提交回复
热议问题