Skip to content

Instantly share code, notes, and snippets.

@bradorego
Created December 12, 2016 15:37
Show Gist options
  • Save bradorego/c9ea8b669d3b9d0914c4bf25184dcb3a to your computer and use it in GitHub Desktop.
Save bradorego/c9ea8b669d3b9d0914c4bf25184dcb3a to your computer and use it in GitHub Desktop.
var uploadVideo = function (file, title, description) {
var d = $q.defer();
youtube.videos.insert({
part: 'snippet,status',
resource: {
snippet: {
title: title,
description: description
},
status: {
privacyStatus: "unlisted"
}
},
media: {
mimeType: file.mimetype,
body: fs.readFileSync(file.path)
}
}, function (err, result, response) {
if (err) {
console.error(err);
return d.reject(err);
}
del.sync([file.path]); /// clean up file after upload success
//// save stuff to user records...which means I'll need to pass user info in
// var videoId = "J31_ux8XxFs", ///result.id,
// playlistId = "PLl-EhCUbHyIBAhfdPTrS7K35107IbjopG";
d.resolve(result);
}); /// end video upload
return d.promise;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment