I send request to https://api.cloudflare.com/client/v4/accounts/<accountID>/stream?direct_user=true
with curl in PHP, and get header location value as upload link then pass it to java Script.
this link is like this:
https://upload.videodelivery.net/tus/xxxxxx?tusv2=true
and in JS use tus.js for uploading video:
var file = document.querySelector('#video').files[0];
var options = {
uploadUrl: 'https://upload.videodelivery.net/tus/xxxxxx?tusv2=true',
chunkSize: 50 * 1024 * 1024,
retryDelays: [0, 3000, 5000, 10000, 20000],
parallelUploads: 1,
metadata: {
filename: file.name,
filetype: file.type,
},
headers: {
'Authorization': 'Bearer <Token>',
'Tus-Resumable': '1.0.0'
},
}
upload = new tus.Upload(file, options)
upload.start();
but, requests was blocked. what is solution?
with the help of cloud-flare team, I found the solution. There is no need to send
Authorization
andTus-Resumable
header on the second request sent via TUS upload.