Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(publisher-s3): allow ACL omission #3728

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/publisher/s3/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export interface PublisherS3Config {
* Default: false
*/
public?: boolean;
/**
* Whether to omit the ACL when creating the S3 object
JHartman5 marked this conversation as resolved.
Show resolved Hide resolved
*
* Default: false
*/
omitAcl?: boolean;
/**
* The endpoint URI to send requests to.
*
Expand Down
17 changes: 10 additions & 7 deletions packages/publisher/s3/src/PublisherS3.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';

import { S3Client } from '@aws-sdk/client-s3';
import { PutObjectCommandInput, S3Client } from '@aws-sdk/client-s3';
import { Progress, Upload } from '@aws-sdk/lib-storage';
import { Credentials } from '@aws-sdk/types';
import { PublisherOptions, PublisherStatic } from '@electron-forge/publisher-static';
Expand Down Expand Up @@ -59,15 +59,18 @@ export default class PublisherS3 extends PublisherStatic<PublisherS3Config> {
await Promise.all(
artifacts.map(async (artifact) => {
d('uploading:', artifact.path);
const params: PutObjectCommandInput = {
Body: fs.createReadStream(artifact.path),
Bucket: this.config.bucket,
Key: this.keyForArtifact(artifact),
};
if (!this.config.omitAcl) {
params.ACL = this.config.public ? 'public-read' : 'private';
}
const uploader = new Upload({
client: s3Client,
leavePartsOnError: true,
params: {
Body: fs.createReadStream(artifact.path),
Bucket: this.config.bucket,
Key: this.keyForArtifact(artifact),
ACL: this.config.public ? 'public-read' : 'private',
},
params,
});

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