Created
July 10, 2018 22:27
-
-
Save luislobo/16854062338eec2940d4416614c02741 to your computer and use it in GitHub Desktop.
upload from an http resource into s3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stream = require('stream'); | |
const request = require('request'); | |
const AWS = require('aws-sdk'); | |
const s3 = new AWS.S3(); | |
const BUCKET = 'mybucket'; | |
const KEY = 'luis/yourvideo.mp4'; | |
request.get('https://yoursite/yourvideo.mp4') | |
.pipe(uploadFromStream()) | |
function uploadFromStream() { | |
var pass = new stream.PassThrough(); | |
var params = {Bucket: BUCKET, Key: KEY, Body: pass}; | |
s3.upload(params, function(err, data) { | |
console.log(err, data); | |
}); | |
return pass; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment