Skip to content

Commit 2c59559

Browse files
committed
Small improvements on ACL support, bump to version 1.2.0
1 parent 35a0c9f commit 2c59559

File tree

2 files changed

+10
-29
lines changed

2 files changed

+10
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "s3-batch-upload",
3-
"version": "1.1.2",
3+
"version": "1.2.0",
44
"description": "Super fast batched S3 folder uploads from CLI or API.",
55
"main": "./index.js",
66
"types": "./index.d.ts",

src/lib/Uploader.ts

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,9 @@ export type Options = {
2121
dryRun?: boolean;
2222
cacheControl?: string | { [key: string]: string };
2323
s3Client?: S3;
24-
accessControlLevel?: ObjectACL;
24+
accessControlLevel?: S3.ObjectCannedACL;
2525
};
2626

27-
export type ObjectACL =
28-
| 'private'
29-
| 'public-read'
30-
| 'public-read-write'
31-
| 'authenticated-read'
32-
| 'aws-exec-read'
33-
| 'bucket-owner-read'
34-
| 'bucket-owner-full-control'
35-
| string;
36-
3727
const defaultOptions = {
3828
dryRun: false,
3929
concurrency: 100,
@@ -119,24 +109,15 @@ export default class Uploader {
119109
public uploadFile(localFilePath: string, remotePath: string): Promise<void> {
120110
const body = fs.createReadStream(localFilePath);
121111
const { dryRun, bucket: Bucket, accessControlLevel: ACL } = this.options;
122-
let params;
112+
const params: S3.PutObjectRequest = {
113+
Bucket,
114+
Key: remotePath.replace(/\\/g, '/'),
115+
Body: body,
116+
ContentType: mime.getType(localFilePath),
117+
CacheControl: this.getCacheControlValue(localFilePath),
118+
};
123119
if (ACL) {
124-
params = {
125-
ACL,
126-
Bucket,
127-
Key: remotePath.replace(/\\/g, '/'),
128-
Body: body,
129-
ContentType: mime.getType(localFilePath),
130-
CacheControl: this.getCacheControlValue(localFilePath),
131-
};
132-
} else {
133-
params = {
134-
Bucket,
135-
Key: remotePath.replace(/\\/g, '/'),
136-
Body: body,
137-
ContentType: mime.getType(localFilePath),
138-
CacheControl: this.getCacheControlValue(localFilePath),
139-
};
120+
params.ACL = ACL;
140121
}
141122

142123
return new Promise(resolve => {

0 commit comments

Comments
 (0)