Skip to content

Commit

Permalink
optional path on bucket to store uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Schaer committed Jul 17, 2015
1 parent debdfb1 commit 0aa29e9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/transport/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var FileInfo = require('../fileinfo.js');
* http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getSignedUrl-property
* @param {boolean} [opts.storage.aws.signedUrlExpiresSeconds=900] - For use
* with getSignedUrl=true.
* @param {string} [opts.storage.aws.path] - Path on bucket to store uploads
*
* @example
* awsTransport({
Expand All @@ -40,7 +41,8 @@ var FileInfo = require('../fileinfo.js');
* acl: 'public-read',
* cacheControl: 'max-age=630720000, public',
* expiresInMilliseconds: 63072000000,
* getSignedUrl: false
* getSignedUrl: false,
* path: 'uploads/'
* }
* }
* });
Expand Down Expand Up @@ -160,7 +162,7 @@ function uploadFile(s3, fileName, filePath, opts, callback) {
var params = {
ACL: opts.acl,
Bucket: opts.bucketName,
Key: remoteFilename,
Key: (opts.path || '') + remoteFilename,
Body: fileBuffer,
ContentType: metaData
};
Expand Down Expand Up @@ -188,7 +190,7 @@ function uploadFile(s3, fileName, filePath, opts, callback) {
Expires: opts.signedUrlExpires || 900
});
} else {
url = s3.endpoint.href + opts.bucketName + '/' + remoteFilename;
url = s3.endpoint.href + opts.bucketName + '/' + opts.path + remoteFilename;
}

callback(error,{ url: url});
Expand Down

0 comments on commit 0aa29e9

Please sign in to comment.