bloody-simple-s3
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -0,1 +1,5 @@ | ||
## 0.3.1 - 2015-04-06 | ||
* Add #readBuffer method to read the contents of a file from S3 | ||
## 0.3.0 - 2015-04-03 | ||
@@ -2,0 +6,0 @@ |
@@ -9,2 +9,3 @@ # Bloody Simple S3 | ||
* [writeFile(filename, contents, [callback])](#writeFile) | ||
* [readBuffer(filename, [callback])](#readBuffer) | ||
* [list(dir, options, [callback])](#list) | ||
@@ -104,2 +105,27 @@ * [copy(source, destination, [callback])](#copy) | ||
### <a name="readBuffer" href="#readBuffer">#</a>readBuffer(filename, [callback]) -> Promise | ||
Reads the designated file from S3 and returns a buffer. | ||
##### Parameters | ||
* `filename` _(String)_ file path on S3 | ||
* `callback` _(Function)_ optional callback function with (err, buf) arguments | ||
##### Returns | ||
A promise resolving to a buffer. | ||
##### Example | ||
```javascript | ||
s3.readBuffer('images/test.png') | ||
.then(function (buf) { | ||
// do something with buf | ||
}) | ||
.catch(function (err) { | ||
console.error(err); | ||
}); | ||
``` | ||
### <a name="list" href="#list">#</a>list(dir, options, [callback]) -> Promise | ||
@@ -106,0 +132,0 @@ |
{ | ||
"name": "bloody-simple-s3", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "A bloody simple interface to S3, based on the official AWS sdk", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -25,3 +25,3 @@ # Bloody simple S3 | ||
s3.upload('/Users/john/Photos/monkey.jpg', 'images/monkey-1.jpg) | ||
s3.upload('/Users/john/Photos/monkey.jpg', 'images/monkey-1.jpg') | ||
.then(function (file) { | ||
@@ -45,3 +45,3 @@ console.log(file.path); | ||
* Node.js 0.8+* | ||
* Node.js 0.8+ | ||
@@ -48,0 +48,0 @@ ## Contribute |
@@ -118,2 +118,25 @@ var path = require('path'); | ||
BloodySimpleS3.prototype.readBuffer = function (filename, callback) { | ||
var _this = this; | ||
var resolver; | ||
resolver = function(resolve, reject) { | ||
var readable = _this.createReadStream(filename); | ||
var buf = []; | ||
readable.on('data', function(d) { | ||
buf.push(d); | ||
}); | ||
readable.on('end', function() { | ||
resolve(Buffer.concat(buf)); | ||
}); | ||
readable.on('error', reject); | ||
}; | ||
return new Promise(resolver) | ||
.nodeify(callback); | ||
}; | ||
BloodySimpleS3.prototype.writeFile = function (filename, contents, callback) { | ||
@@ -120,0 +143,0 @@ var _this = this; |
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
95394
390