gcm50
September 9, 2019, 8:29pm
1
Hello!
When utilizing Uppy with the tus plugin is possible to provide unique headers per file instead of simply setting them globally in the tus options?
For example, is it possible to include each files total file size as a custom header in all upload requests for that file (POST/HEAD/PATCH)?
Alternatively, is there an option to send the Upload-Metadata in each request instead of only sending it in the initial POST to create the upload?
Any help would be greatly appreciated! Uppy and tus have been a joy to work with :)!
gcm50
September 9, 2019, 9:53pm
2
After some more time investigating it appears there is a per file tus options override that is outlined in the tus upload method:
Utilizing this and the onBeforeUpload
uppy option it appears you can override the headers per file like so:
onBeforeUpload: (files: any) => {
const updatedFiles = Object.assign({}, files);
Object.keys(updatedFiles).forEach(fileId => {
updatedFiles[fileId].tus = {
headers: {
'FILE_SIZE': updatedFiles[fileId].size,
'TEST_HEADER': 'test value'
}
};
});
return updatedFiles;
}
I would still be happy to hear any other suggestions or thoughts on this solution! Cheers!