Improve environment variable stuff
This commit is contained in:
parent
760ee07a2e
commit
6ba174cff0
16 changed files with 66 additions and 64 deletions
10
lib/s3.js
10
lib/s3.js
|
@ -3,17 +3,15 @@ import s3UploadStream from 's3-upload-stream';
|
|||
import debugname from 'debug';
|
||||
const debug = debugname('hostr:s3');
|
||||
|
||||
const bucket = process.env.AWS_BUCKET || 'hostrdotcodev';
|
||||
|
||||
const s3 = new aws.S3();
|
||||
const s3Stream = s3UploadStream(s3);
|
||||
|
||||
export function get(key) {
|
||||
debug('fetching file: %s', 'hostr_files/' + key);
|
||||
return s3.getObject({Bucket: bucket, Key: 'hostr_files/' + key}).createReadStream();
|
||||
debug('fetching from s3: %s', 'hostr_files/' + key);
|
||||
return s3.getObject({Bucket: process.env.AWS_BUCKET, Key: 'hostr_files/' + key}).createReadStream();
|
||||
}
|
||||
|
||||
export function upload(key) {
|
||||
debug('Uploading file: %s', 'hostr_files/' + key);
|
||||
return s3Stream.upload({Bucket: bucket, Key: 'hostr_files/' + key});
|
||||
debug('sending to s3: %s', 'hostr_files/' + key);
|
||||
return s3Stream.upload({Bucket: process.env.AWS_BUCKET, Key: 'hostr_files/' + key});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue