上传从S3到YouTube的文件,使用此代码:上传从S3文件到YouTube上使用Node.js的
s3.setBucket('MyBucket');
s3.get('MyBucket/5/' + filename, null, 'stream', function(err, response) {
googleapis.discover('youtube', 'v3').execute(function(err, client) {
var metadata = {
snippet: { title: title, description: description},
status: { privacyStatus: 'public' }
};
client
.youtube.videos.insert({ part: 'snippet,status'}, metadata)
.withMedia('video/mp4', response)
.withAuthClient(auth)
.execute(function(err, result) {
if (err) console.log(err);
else console.log(JSON.stringify(result, null, ' '));
response.redirect('/share?set=yt&id=' + result.id);
}); }); });
不起作用,因为线:
.withMedia( '视频/ MP4',响应)
这是一个替代原来的一个,即作品:
fs.readFileSync(“/温度/ myfile.png”)
换句话说:如果我上传本地文件在我的笔记本电脑,这将工作,因为我使用的文件系统对象。
Google API是否允许从文件流上传?如果没有,那么你需要首先将文件作为临时文件下载,然后从那里上传。 – datasage
不知道这是否允许:(并且也没有太多的文档:) – user3465009
Stream to stream copy对两个API都支持它更高效,否则你可能需要将文件写入临时磁盘位置并从 – datasage