Created
February 25, 2018 21:14
-
-
Save tphummel/463403415817305d8803a83b498d2677 to your computer and use it in GitHub Desktop.
pipe the content of a webpage to a file in s3
This file contains 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
var http = require('http') | |
var path = require('path') | |
var AWS = require('aws-sdk') | |
function httpToS3 (event, context, callback) { | |
var s3 = new AWS.S3() | |
var now = (new Date()).toISOString() | |
http.request({ | |
protocol: 'http:', | |
hostname: 'www.nracountry.com', | |
path: '/artists', | |
method: 'GET' | |
}, function (res) { | |
s3.upload({ | |
Bucket: 'my-bucket', | |
Key: path.join('nra-country', now + '.txt'), | |
Body: res | |
}, {}, function (err, data) { | |
console.log(data) | |
callback(err, 'all done') | |
}) | |
}).end() | |
} | |
// httpToS3({}, {}, (err, msg) => { | |
// console.log(err, msg) | |
// }) | |
exports.handler = httpToS3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment