Closed tdewolff closed 3 weeks ago
I was thinking that PreUploadCreateCallback would accomplish this, but somehow the metadata I return is not included in the metadata variable in the JS client (is this a bug?)
This is the expected behavior. Metadata is only returned for HEAD requests, so the client would have to manually fetch the metadata via an extra HEAD request.
Additionally, the HTTPResponse headers set aren't visible in the JS client either (it somehow filters on known TUS header fields it seems, bug as well?)
I suspect that this is a CORS issue. Did you add the header you are setting to -cors-expose-headers
? If not, browser will hide these headers from JS as far as I know. Please see https://tus.github.io/tusd/getting-started/configuration/#cross-origin-resource-sharing-cors.
Thank you Marius for the help!
Glad to hear it helped! I also just updated the documentation, so that other users can discover this on their own.
I'm using the library of tusd integrated in my application. Uploading using the tus-js-client works perfect, but I'd like to send back a variable to the JS client. Specifically, for every new uploaded file, and URL is created, specific to my application, to which I wish to redirect the user after upload is complete. I was thinking that PreUploadCreateCallback would accomplish this, but somehow the metadata I return is not included in the metadata variable in the JS client (is this a bug?). Additionally, the HTTPResponse headers set aren't visible in the JS client either (it somehow filters on known TUS header fields it seems, bug as well?). I wanted to implement this from the PreFinishResponseCallback, but it doesn't allow setting metadata.
What is the recommended way to send custom variables to a client?