I'm following the Vimeo api's guide about resumable uploads (https://developer.vimeo.com/api/upload/videos#resumable-tus-upload).
I get a response after the first request but I get an undefined
response for the second request (step 2. Upload the video file).
The guide tells to PATCH the binary data of the video file to the URL from upload.upload_link. I'm using readAsBinaryString()
to convert the video file to binary data (I have tried also readAsArrayBuffer()
but with the same result. What am I possibly doing wrong?
This is the code:
var reader = new FileReader();
$.ajax({
'url': 'https://api.vimeo.com/me/videos',
'type': 'POST',
'headers': {
'Accept': 'application/vnd.vimeo.*+json;version=3.4',
'Content-Type': 'application/json',
'Authorization': 'bearer ' + accessToken
},
"data": JSON.stringify({
"upload" : {
"approach" : "tus",
"size" : fileSize
}
}),
'success': function (result) {
$.ajax({
'url': result.upload.upload_link,
'type': 'PATCH',
'headers': {
'Tus-Resumable': '1.0.0',
'Upload-Offset': 0,
'Content-Type': 'application/offset+octet-stream'
},
'data': reader.readAsBinaryString(fileContent),
'success': function (result) {
console.log(result)
}
});
}
});