-
-
Save dannycoates/f75e37df25968ff74475156b894669d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const conf = require('./config.js'); | |
const fs = require('fs'); | |
const AWS = require('aws-sdk'); | |
if (conf.s3_bucket) { | |
const bucket = new AWS.S3({ params: { Bucket: conf.s3_bucket } }); | |
module.exports = { | |
length: function(id) { | |
return bucket.headObject({ Key: id }).promise(); | |
}, | |
get: function(id) { | |
return bucket.getObject({ Key: id }).createReadStream(); | |
}, | |
set: function(id, stream) { | |
return bucket.upload({ Key: id, Body: stream }).promise(); | |
}, | |
del: function(id) { | |
return bucket.deleteObject({ Key: id }).promise(); | |
} | |
}; | |
} else { | |
module.exports = { | |
length: function(id) {}, | |
get: function(id) {}, | |
set: function(id, stream) {}, | |
del: function(id) {} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment