Open jaimykumar opened 2 years ago
Hi,
Looking at the documentation for the insert
method here, it looks like you have the correct parameters. It looks like the media parameter accepts any readable stream.
To create a readable stream out of your buffer you can do this:
import { Readable } from 'stream'
const readable = new Readable()
readable.push(req.files.video)
Then change the media paramater to:
media: {
body: readable,
mimeType: "video/*"
}
I haven't tested this so it may be wrong but I hope that helps!
Hi, community, I use node js and google API NPM with both I want to upload a video on the user's youtube account but I couldn't figure out how to pass the request.file into the insert function of the package, I know that for local files i have to use fs.createReadStream() but for request.file I can not use that so how can I pass video file data to youtube api?
I tried with some thing buffer but not working:- service.videos.insert( { auth: oauth2Client, part: "snippet,status", requestBody: { snippet: { title: "Xyz2", description: "abc", categoryId: 28, defaultAudioLanguage: "en", defaultLanguage: "en", }, status: { privacyStatus: "public", }, }, media: { mimeType:"video/*", body: Buffer.from(req.files.video),