I'm trying to upload a public video file from Amazon S3 to Dailymotion using a NodeJS Lambda function. AWS Lambda functions have a storage limitation: I can't download the whole video file locally on the serverless function and then send it to Dailymotion.
I searched for a way to read the file on parts and send them with HTTPS requests to Dailymotion, and I found the urllib library that seems helpful!
To upload a video file to Dailymotion, you can send a POST request to an UPLOAD_URL that should be generated using another authenticated request:
curl -X POST \
-F 'file=@/path/to/your/video.mp4' \
'<UPLOAD_URL>'
The steps are clearly mentioned on this document page.
What I need is a way to stream the file from a URL like this https://cdn.example.com/videos/filename.mp4 to Dailymotion through my Lambda function.
Anyone with good experience can help with a clear example of how to do it.
I found a solution using
requestandform-datalibraries. Just:request.callbackback to the caller with the response.Here's a working copy of my Lambda function code:
Update
Another solution using the
httpsnative module of Nodejs instead of the deprecatedrequestlibrary: