Hello all!
I am currently trying to upload a video to youtube purely client-side. I
have managed to get Oauth working (following this example:
https://developers.google.com/youtube/v3/code_samples/javascript ). I have
also gotten *very* close to getting the actual upload to work doing this
<form method="post" enctype="multipart/form-data">
<input type="file" id="fileToSend"/>
<input type="button" onclick="createVideo()" value="Upload"
id="btnSend"/>
</form>
function createVideo() {
var fileStream;
var video = document.getElementById("fileToSend");
var file = video.files[0];
console.log(file);
console.log("Nombre: " + file.name);
var r = new FileReader();
var that = gapi
r.onload = function () {
console.log("fileStream creado");
fileStream = r.result;
//console.log("FileStream: " + fileStream);
gapi.client.load('youtube', 'v3',
function() {
var request = gapi.client.youtube.videos.insert({
part: 'snippet, status',
resource: {
"snippet": {
"title": "My video title",
"description": "This is a description of my video",
"tags": ["cool", "video", "more keywords"],
"categoryId": 22,
"mediaBody": fileStream
},
"status": {
"privacyStatus": "public",
"embeddable": true,
"license": "youtube"
},
}
})
request.execute(function (response) {
console.log("executing..");
var result = response.result;
console.log(response);
if (result) {
console.log("execute completed");
document.write(result);
}
});
});
}
console.log("Creando fileStream..");
r.readAsBinaryString(file);
When I say very close, I mean that I can actually log into my youtube
account, and see that it tried to post the video, and it'll infinitely say
it's "processing". The response I get back is an error saying
"mediaBodyRequired", which upon googling means "video ain't attaching".
That's all well and good, but I don't really know where or how to attach
the video...Does anyone here know of a good way to go about doing that?
--
--
You received this message because you are subscribed to the Google
Groups "Google AJAX APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
To view this message on the web, visit
https://groups.google.com/d/msgid/google-ajax-search-api/99194e09-6ef3-43a8-b875-ddb7af40fda0%40googlegroups.com
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"Google AJAX APIs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.