Skip to content

Commit

Permalink
Small improvements on ACL support, bump to version 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaNarie committed Jun 9, 2019
1 parent 35a0c9f commit 2c59559
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "s3-batch-upload",
"version": "1.1.2",
"version": "1.2.0",
"description": "Super fast batched S3 folder uploads from CLI or API.",
"main": "./index.js",
"types": "./index.d.ts",
Expand Down
37 changes: 9 additions & 28 deletions src/lib/Uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,9 @@ export type Options = {
dryRun?: boolean;
cacheControl?: string | { [key: string]: string };
s3Client?: S3;
accessControlLevel?: ObjectACL;
accessControlLevel?: S3.ObjectCannedACL;
};

export type ObjectACL =
| 'private'
| 'public-read'
| 'public-read-write'
| 'authenticated-read'
| 'aws-exec-read'
| 'bucket-owner-read'
| 'bucket-owner-full-control'
| string;

const defaultOptions = {
dryRun: false,
concurrency: 100,
Expand Down Expand Up @@ -119,24 +109,15 @@ export default class Uploader {
public uploadFile(localFilePath: string, remotePath: string): Promise<void> {
const body = fs.createReadStream(localFilePath);
const { dryRun, bucket: Bucket, accessControlLevel: ACL } = this.options;
let params;
const params: S3.PutObjectRequest = {
Bucket,
Key: remotePath.replace(/\\/g, '/'),
Body: body,
ContentType: mime.getType(localFilePath),
CacheControl: this.getCacheControlValue(localFilePath),
};
if (ACL) {
params = {
ACL,
Bucket,
Key: remotePath.replace(/\\/g, '/'),
Body: body,
ContentType: mime.getType(localFilePath),
CacheControl: this.getCacheControlValue(localFilePath),
};
} else {
params = {
Bucket,
Key: remotePath.replace(/\\/g, '/'),
Body: body,
ContentType: mime.getType(localFilePath),
CacheControl: this.getCacheControlValue(localFilePath),
};
params.ACL = ACL;
}

return new Promise(resolve => {
Expand Down

0 comments on commit 2c59559

Please sign in to comment.