bloody-simple-s3
Advanced tools
Comparing version 0.1.5 to 0.1.6
{ | ||
"name": "bloody-simple-s3", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "A bloody simple interface to S3, based on the official AWS sdk.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -52,22 +52,22 @@ var path = require('path'), | ||
* @return {ReadableStream} | ||
* @throws {Error} if options are invalid. | ||
*/ | ||
BloodySimpleS3.prototype.getObjectStream = function (options) { | ||
var key, params; | ||
var key; | ||
// validate options | ||
if (!_.isPlainObject(options)) { | ||
return Promise.reject('Invalid request options, expected plain object, received ' + typeof(options)); | ||
throw new Error('Invalid request options, expected plain object, received ' + typeof(options)); | ||
} | ||
// extract key from options + validate | ||
key = options.key; | ||
if (!_.isString(key)) { | ||
return Promise.reject('Invalid object key, expected string, received ' + typeof(key)); | ||
throw new Error('Invalid object key, expected string, received ' + typeof(key)); | ||
} | ||
params = _.extend(options, { | ||
return this.s3.getObject({ | ||
Key: key, | ||
Bucket: this.bucket | ||
}); | ||
return this.s3.getObject(params).createReadStream(); | ||
}).createReadStream(); | ||
}; | ||
@@ -90,9 +90,18 @@ | ||
if (!_.isPlainObject(options)) return Promise.reject('Invalid request options, expected plain object, received ' + typeof(options)); | ||
// validate options | ||
if (!_.isPlainObject(options)) { | ||
reject('Invalid request options - expected plain object, received ' + typeof(options)); | ||
return; | ||
} | ||
// extract key from options + validate | ||
key = options.key; | ||
if (!_.isString(key)) { | ||
reject('Invalid object key - expected string, received ' + typeof(key)); | ||
return; | ||
} | ||
destination = options.destination || os.tmpdir(); | ||
if (!_.isString(key)) return Promise.reject('Invalid object key, expected string, received ' + typeof(key)); | ||
// make sure destination is either file or folder | ||
fs.stat(destination, function (err, stats) { | ||
@@ -255,3 +264,5 @@ var target, writable, readable; | ||
// s3.download('apk/lean-canvas.pdf').then(function (filePath) { | ||
// s3.download({ | ||
// key: 'apk/com.canned.recipes_v1.apk' | ||
// }).then(function (filePath) { | ||
// console.log(filePath); | ||
@@ -258,0 +269,0 @@ // }).catch(function (err) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11791
264