使用Node.js上传时设置YouTube视频标题(googleapi模块v1.0)

使用Node.js上传时设置YouTube视频标题(googleapi模块v1.0),node.js,upload,youtube,youtube-api,google-api-nodejs-client,Node.js,Upload,Youtube,Youtube Api,Google Api Nodejs Client,我正在尝试使用Node.js(YouTube API V3)中的googleapi模块将视频上传到我的YouTube频道 视频上传很好-我就是找不到如何将标题和描述传递给上传命令 这是我的代码: //Authorization stuff above fs.readFile('./youtube_videos/in.avi', function(err, content){ if(err){ console.log('read file error: '+err);

我正在尝试使用Node.js(YouTube API V3)中的
googleapi
模块将视频上传到我的YouTube频道

视频上传很好-我就是找不到如何将标题和描述传递给上传命令

这是我的代码:

//Authorization stuff above

fs.readFile('./youtube_videos/in.avi', function(err, content){
    if(err){
        console.log('read file error: '+err);
    } else {
        yt.videos.insert({
            part: 'status,snippet',
            autoLevels: true,
            media: {
                body: content
            }
        }, function(error, data){
            if(error){
                console.log('error: '+error);
            } else {
                console.log('https://www.youtube.com/watch?v='+data.id+"\r\n\r\n");
                console.log(data);
            }
        });
    }
})
我知道应该如何像传递对象一样传递一些
代码片段

snippet: {
    title: 'test upload2',
    description: 'My description2',
}
但我找不到应该放在哪里——我尝试了所有(几乎)可能的组合

谢谢大家!

我找到了答案 如果有人在找它- 代码段应该是请求选项中
资源
对象的一部分

(我还将
fs.readFile
转换为
fs.createReadStream

function uploadToYoutube(video_file, title, description,tokens, callback){
    var google = require("googleapis"),
        yt = google.youtube('v3');

    var oauth2Client = new google.auth.OAuth2(clientId, appSecret, redirectUrl);
    oauth2Client.setCredentials(tokens);
    google.options({auth: oauth2Client});

    return yt.videos.insert({
        part: 'status,snippet',
        resource: {
            snippet: {
                title: title,
                description: description
            },
            status: { 
                privacyStatus: 'private' //if you want the video to be private
            }
        },
        media: {
            body: fs.createReadStream(video_file)
        }
    }, function(error, data){
        if(error){
            callback(error, null);
        } else {
            callback(null, data.id);
        }
    });
};