Skip to content

Commit 2b6da59

Browse files
feat(publisher-s3): allow ACL omission (#3728)
* feat(publisher-s3): allow ACL omission This allows the caller to omit the ACL from the upload request, per Amazon's recommendation of using bucket owner-enforced permissions. * Update packages/publisher/s3/src/Config.ts Updates the documentation for the `omitAcl` option per the pull request review Co-authored-by: Felix Rieseberg <[email protected]> --------- Co-authored-by: Felix Rieseberg <[email protected]>
1 parent f947936 commit 2b6da59

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

packages/publisher/s3/src/Config.ts

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ export interface PublisherS3Config {
3838
* Default: false
3939
*/
4040
public?: boolean;
41+
/**
42+
* Whether to omit the ACL when creating the S3 object. If set, `public` will have no effect.
43+
*
44+
* Default: false
45+
*/
46+
omitAcl?: boolean;
4147
/**
4248
* The endpoint URI to send requests to.
4349
*

packages/publisher/s3/src/PublisherS3.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs';
22
import path from 'path';
33

4-
import { S3Client } from '@aws-sdk/client-s3';
4+
import { PutObjectCommandInput, S3Client } from '@aws-sdk/client-s3';
55
import { Progress, Upload } from '@aws-sdk/lib-storage';
66
import { Credentials } from '@aws-sdk/types';
77
import { PublisherOptions, PublisherStatic } from '@electron-forge/publisher-static';
@@ -59,15 +59,18 @@ export default class PublisherS3 extends PublisherStatic<PublisherS3Config> {
5959
await Promise.all(
6060
artifacts.map(async (artifact) => {
6161
d('uploading:', artifact.path);
62+
const params: PutObjectCommandInput = {
63+
Body: fs.createReadStream(artifact.path),
64+
Bucket: this.config.bucket,
65+
Key: this.keyForArtifact(artifact),
66+
};
67+
if (!this.config.omitAcl) {
68+
params.ACL = this.config.public ? 'public-read' : 'private';
69+
}
6270
const uploader = new Upload({
6371
client: s3Client,
6472
leavePartsOnError: true,
65-
params: {
66-
Body: fs.createReadStream(artifact.path),
67-
Bucket: this.config.bucket,
68-
Key: this.keyForArtifact(artifact),
69-
ACL: this.config.public ? 'public-read' : 'private',
70-
},
73+
params,
7174
});
7275

7376
uploader.on('httpUploadProgress', (progress: Progress) => {

0 commit comments

Comments
 (0)