0

I have a form for downloading files and I want to add {'Authorization': 'Token' + tokenString} header for backend authorization. However I heard that AJAX can't save responses as files so I used <form action="download_url">.

The problem here is that I don't know how to add custom header to this form request, so anyone can download the files with right link. How the header be added? Or is there another way around it?

Zygro
  • 6,849
  • 11
  • 28
  • 43

1 Answers1

1

Option 1: Use a cookie instead of a custom header. You can set this cookie via JS.

Option 2: You can let the user download an XHR response (see this question.

Community
  • 1
  • 1
Johan de Vries
  • 175
  • 1
  • 9