Skip to content

Instantly share code, notes, and snippets.

@luislobo
Created July 10, 2018 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luislobo/16854062338eec2940d4416614c02741 to your computer and use it in GitHub Desktop.
Save luislobo/16854062338eec2940d4416614c02741 to your computer and use it in GitHub Desktop.
upload from an http resource into s3
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