Skip to content

Instantly share code, notes, and snippets.

@tphummel
Created February 25, 2018 21:14
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 tphummel/463403415817305d8803a83b498d2677 to your computer and use it in GitHub Desktop.
Save tphummel/463403415817305d8803a83b498d2677 to your computer and use it in GitHub Desktop.
pipe the content of a webpage to a file in s3
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