-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Closed
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.
Description
I think, it's a bug
I'm trying to upload video with youtube v3 API, looking on this example.
So, I wrote something like this:
var xhr = new XMLHttpRequest();
xhr.open('PUT', this.url, true);
xhr.setRequestHeader('Content-Type', this.contentType); <=== video/mp4
xhr.setRequestHeader('Content-Range', 'bytes ' + this.offset + '-' + (end - 1) + '/' + this.filesize);
xhr.setRequestHeader('X-Upload-Content-Type', this.filetype); <=== video/mp4
if (xhr.upload) {
xhr.upload.addEventListener('progress', this.onProgress);
}
xhr.onload = this.onContentUploadSuccess_.bind(this);
xhr.onerror = this.onContentUploadError_.bind(this);
xhr.send({uri: this.file.path}); <=== file:///.....
and it works, i have xhr.onload
and xhr.onerror
and video file is uploaded to youtube and played there.
But i haven't xhr.upload.onprogress
.
I try xhr.onprogress
, xhr.upload.onprogress
, xhr.upload.addEventListener
- all of this not works.
BUT!
When i use FormData
let data = new FormData();
data.append('File', {
uri: source.path,
type: source.type,
name: source.name
});
var xhr = new XMLHttpRequest();
xhr.open('PUT', this.url, true);
//xhr.setRequestHeader('Content-Type', this.contentType);
//=== comment this, because it throw error 'multipart != video/mp4'
//xhr.setRequestHeader('Content-Range', 'bytes ' + this.offset + '-' + (end - 1) + '/' + this.filesize);
//=== comment this, because sending data size != filesize
xhr.setRequestHeader('X-Upload-Content-Type', this.filetype);
if (xhr.upload) {
xhr.upload.addEventListener('progress', this.onProgress);
}
xhr.onload = this.onContentUploadSuccess_.bind(this);
xhr.onerror = this.onContentUploadError_.bind(this);
xhr.send(data); <==== FormData
xhr.upload.onprogress
is working. But then youtube api return processing error, because it support only 'video/*' and 'application/octet-stream' and does not support 'multipart/form-data'.
What I do wrong and what I need to do for using xhr.upload.onprogress
WITHOUT FormData
?
P.S. sorry for my ugly english
react-native v0.47.2
:node v8.2.1
:npm v5.3.0
:
- Target Platform: Android
- Development Operating System: MacOS
- Build tools: Android SDK
ceefour
Metadata
Metadata
Assignees
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.