Koop-FileSystem-S3
Koop integration with Amazon S3
Install
koop-s3fs should be installed as a dependency in a Node.js project like so:
npm install koop-s3fs --save
Config
koop-s3fs requires a json config file like so:
{
"filesystem": {
"s3": {
"bucket": $S3_BUCKET,
"endpoint" $S3-ENDPOINT //optional https://forums.aws.amazon.com/ann.jspa?annID=3112
}
}
}
Additionally you will need to supply your:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
or configure the AWS CLI with keys.
Methods
const Filesystem = require('koop-s3fs')
const s3fs = new Filesystem()
const fs = require('fs')
const stream = fs.createReadStream('path/to/file')
.pipe(s3fs.createWriteStream('filename'))
s3fs.createReadStream('filename').toArray(arr => {
const txt = arr.toString()
console.log(txt)
})
s3fs.stat('filename', (err, data) => {
console.log(data)
})