Custom Location Header
See original GitHub issueI’m working in a project that I need to generate a presigned Url for upload and would be nice if was possible to send a custom Location
header with client query params. The actual behavior of tusdotnet is call SetReponseHeaders
after file creation so is no possible to override the generated Location.
For exemple:
- Client send and request to my API endpoint
- Then my API with validate the user grants and return a presigned upload url, like that
https://localhost/upload?token=12345
- Client do a tus upload to the presigned url given from API
- My tus server will keep it on Location header, like that
Response.Location = $"/upload/{ctx.fileId}?token=12345"
- So that when my client can continue the PATCH requests to the Location response with presigned params
- Then
OnFileCompleteAsync
my tus server can have access to client query params and do some insert based on token data
Would be nice to have the concept above, where tus server can keep or customize the final Location header.
I’m already using a similar approach that I send the token on a Upload-Token
header, but custom Location headers will give more control for server.
Issue Analytics
- State:
- Created a year ago
- Comments:8
Top Results From Across the Web
Location - HTTP - MDN Web Docs - Mozilla
Location is a header associated with the response, while Content-Location is associated with the entity returned. Header type, Response header.
Read more >Create custom headers in backend services | Load Balancing
Configure custom response headers · Go to the load balancing summary page. · Click Backends. · Click the name of a backend service....
Read more >Custom HTTP headers : naming conventions
The recommendation is was to start their name with "X-". E.g. X-Forwarded-For , X-Requested-With . This is also mentioned in a.o. section 5 ......
Read more >Content-Location - HTTP - MDN Web Docs - Mozilla
The Content-Location header indicates an alternate location for the returned data. The principal use is to indicate the URL of a resource ...
Read more >Custom Headers <customHeaders>
Custom response headers are sent to the client together with the default HTTP header. Unlike redirect response headers, which are returned in ...
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
@intobrackets In my point of view you’re probably confusing the
Location
header witch where the file will be saved to. If you follow thetus protocol specification
you will see that is divided in many protocol sections.Creation workflow
When a client wants to initiate an upload it will perform a
HTTP POST
request and the server will handle it storing the file metadata and cache stuff.tusdotnet
at this point will triggerOnBeforeCreate
andOnCreateComplete
events and will assign an uuid to after identify the currently upload file.File processing and storing occurs on SERVER SIDE, clients don’t needs to know about file paths or Disk Storing logic, they only need the
Location
for the API UPLOAD ENDPOINTIf you want to customize how server will store the uploaded files, you need to overwrite the file resolution mechanism! Looking to
Xtensible.TusDotNet.Azure
I foundcreate_file_custom_id
test example that will overwrite the file Id creation, maybe can be useful for your use case. After scraping deeper on that library I also found GetAppendBlobClient mechanism. My suggestion is that you need to concatenate thefile id
with some prefix usingXtensible.TusDotNet.Azure
API.Or do a PR for
Xtensible.TusDotNet.Azure
implementing some customcontainer
resolution logic, keep in mind that internal file storing resolution should be entire server side in order to not impact tus protocol comunincation.Thank you @kallebysantos for your reply. I am using Tus (Uppy with Tus on Front + Tusdotnet + Xtensible.TusDotNet.Azure on the Back) to upload files and sotre it into Azule Blob Storage