I'm working on a small project and I'm trying to figure out the best way to do this. I have the following code:
'use strict';
var fs = require('fs');
var through = require('through2');
var parseOSM = require('osm-pbf-parser');
var https = require('https');
exports.handler = (event, context, callback) => {
var request = https.get("https://s3.us-east-2.amazonaws.com/testing-osm/indianapolis_extract.osm.pbf", function(response) {
var osm = parseOSM();
fs.createReadStream(response)
.pipe(osm)
.pipe(through.obj(function (items, enc, next) {
items.forEach(function (item) {
console.log('item=', item);
});
next();
}))
;
});
};
I used NPM to download fs, through2, https, and osm-pbf-parser libraries. When I tried to run it (no special input parameters, just run it), I get the following:
START RequestId: 0a60d8ad-c275-11e6-8d63-f141d0387b78 Version: $LATEST
2016-12-15T03:17:42.860Z 0a60d8ad-c275-11e6-8d63-f141d0387b78 TypeError: path must be a string
at TypeError (native)
at Object.fs.open (fs.js:540:11)
at ReadStream.open (fs.js:1677:6)
at new ReadStream (fs.js:1664:10)
at Object.fs.createReadStream (fs.js:1612:10)
at ClientRequest.<anonymous> (/var/task/index.js:12:6)
I'm not sure if anyone out there has done this before but I'm wanting to get an OSM PBF file from a URL, load it into Lambda, and parse it. I don't need help with anything other than getting it to read the contents of an file.osm.pbf file.
Any help on this is highly appreciated