Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Download a file to a writestream but go directly to a readstream in node.js

$
0
0

I'm trying to upload a file to youtube, using the the googleapis/youtube library. All examples online point to uploading a file from your local filesystem, the code is like this:

const data = await yt.videos.insert({      resource: {        // Video title and description        snippet: {          title: 'test',          description: 'test desc',        },        // I don't want to spam my subscribers        status: {          privacyStatus: 'public',        },      },      // This is for the callback function      part: 'snippet,status',      // Create the readable stream to upload the video      media: {        body: fs.createReadStream(          path.resolve('/Users/username/file.mp4',          ),        ),      },    });

The above code works, however, I want to download a file from a url and immediately pipe it into the call above, replacing the fs.createReadStream and bypassing the local filesystem entirely so I don't have to do cleanup afterwards or hit space limitations in a lambda (/tmp is 500MB max).

I read somewhere else you could use a stream.PassThrough stream but I'm not sure if there's a better way to do this.

TL;DR:I want to go from

URL -> writestream -> filesystem -> readstream -> youtube

to

URL -> writestream -> youtube

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>