hostr/lib/s3.js

15 lines
441 B
JavaScript
Raw Normal View History

2015-07-09 23:01:43 +01:00
import aws from 'aws-sdk';
import debugname from 'debug';
const debug = debugname('hostr:s3');
const s3 = new aws.S3();
export function get(key) {
2016-06-06 13:39:42 +01:00
let fullKey = `hostr_files/${key}`;
if (key.substr(2, 5) === '970/' || key.substr(2, 5) === '150/') {
fullKey = `hostr_files/${key.substr(2)}`;
}
debug('fetching from s3: %s', fullKey);
return s3.getObject({ Bucket: process.env.AWS_BUCKET, Key: fullKey }).createReadStream();
2015-07-09 23:01:43 +01:00
}