Fix S3 connection errors causing crashes

This commit is contained in:
Jonathan Cremin 2019-02-10 00:00:31 +00:00
parent 14f62ac072
commit 78f4c15929
4 changed files with 194 additions and 189 deletions

View file

@ -22,13 +22,15 @@ export function get(key) {
});
}
export function upload(stream, key, callback) {
export function upload(stream, key) {
debug(`sending to s3: uploads/'${key}`);
const params = { Bucket: process.env.AWS_BUCKET, Key: `uploads/${key}`, Body: stream };
const uploading = s3.upload(params);
uploading.on('error', (err) => {
debug('S3 Error', err);
});
uploading.send(callback);
uploading.send((err) => {
debug('S3 Connection Error', err);
});
return uploading;
}