Set http headers on per file basis?
See original GitHub issueHi,
Can I set custom http headers on per file basis? E.g. I would like to send original file name in http header. I use XHR Upload to upload files and I set formData
to false
, because I don’t want to deal with a multipart form on the server. Now have to figure it out how to send file names and possibly some other data (modification date might also be useful).
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
HTTP headers - MDN Web Docs - Mozilla
HTTP Client hints are a set of request headers that provide useful information about the client such as device type and network conditions, ......
Read more >How to Add Custom HTTP Headers to a File or Location
By adding HTTP headers to a file or location, you can provide additional ... This is because Nginx config works on a per...
Read more >Setting headers with an .htaccess file
You can use an .htaccess file to adjust or add headers to your HTTP response headers. Creating an .htaccess file on your DreamHost...
Read more >Adding or modifying headers on HTTP requests and responses
Create new headers · In the Name field, enter the name of your header rule (for example, My header ). · From the...
Read more >Configuring HTTP headers to maintain session state - IBM
To configure HTTP headers to maintain session state, specify the header names in the [session-http-headers] stanza of the WebSEAL configuration file.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is exactly what I was looking for! Thanks!
I put the code inside
'file-added'
event handler, asfile
already exists there (no need to calluppy.getFile
). Also decided not to include...file.xhrUpload
as this property doesn’t exist at that point.Also had to encode file names using
encodeURIComponent()
function, as it turned out thatuppy
doesn’t even start uploading files if I set a header e.g.'Original-File-Name': file.name
and file name contains unicode characters.On server side I then do this (in asp.net controller):
All looks quite nice to me and works great! I don’t think you need to do anything extra on this matter. 😃
There is not a great way to do this, but there is a way. You can use
setFileState
to assign headers:Not the prettiest but it should work. You could do this inside an
uppy.on('upload')
event handler to make sure that the value is updated right before it’s being uploaded.file.xhrUpload
is an undocumented feature but we rely on it in several plugins so it won’t go away in a minor release.This is a common feature request that we’ll hopefully be able to address in a nicer way at some point 😅