Use ES6 => instead of self = this ack
This commit is contained in:
18
S3Adapter.js
18
S3Adapter.js
@@ -31,17 +31,16 @@ function S3Adapter(accessKey, secretKey, options) {
|
|||||||
// For a given config object, filename, and data, store a file in S3
|
// For a given config object, filename, and data, store a file in S3
|
||||||
// Returns a promise containing the S3 object creation response
|
// Returns a promise containing the S3 object creation response
|
||||||
S3Adapter.prototype.create = function(config, filename, data) {
|
S3Adapter.prototype.create = function(config, filename, data) {
|
||||||
var self = this;
|
|
||||||
var params = {
|
var params = {
|
||||||
Key: self.bucketPrefix + filename,
|
Key: this.bucketPrefix + filename,
|
||||||
Body: data,
|
Body: data,
|
||||||
};
|
};
|
||||||
if (self.directAccess) {
|
if (this.directAccess) {
|
||||||
params.ACL = "public-read"
|
params.ACL = "public-read"
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise((resolve, reject) => {
|
||||||
self.s3.upload(params, function(err, data) {
|
this.s3.upload(params, function(err, data) {
|
||||||
if (err !== null) return reject(err);
|
if (err !== null) return reject(err);
|
||||||
resolve(data);
|
resolve(data);
|
||||||
});
|
});
|
||||||
@@ -51,11 +50,10 @@ S3Adapter.prototype.create = function(config, filename, data) {
|
|||||||
// Search for and return a file if found by filename
|
// Search for and return a file if found by filename
|
||||||
// Returns a promise that succeeds with the buffer result from S3
|
// Returns a promise that succeeds with the buffer result from S3
|
||||||
S3Adapter.prototype.get = function(config, filename) {
|
S3Adapter.prototype.get = function(config, filename) {
|
||||||
var self = this;
|
var params = {Key: this.bucketPrefix + filename};
|
||||||
var params = {Key: self.bucketPrefix + filename};
|
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise((resolve, reject) => {
|
||||||
self.s3.getObject(params, function(err, data) {
|
this.s3.getObject(params, (err, data) => {
|
||||||
if (err !== null) return reject(err);
|
if (err !== null) return reject(err);
|
||||||
resolve(data.Body);
|
resolve(data.Body);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user