Skip to content

feat(dl-center): add support for arbitrary acls COMPASS-9237 #525

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

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 15 additions & 0 deletions packages/dl-center/src/download-center.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ describe('download center client', function () {
const content = await downloadCenter.downloadAsset('prefix/asset.txt');
expect(content?.toString()).to.contain('content');
});

it('can upload a file with private acls and download it back', async function () {
await downloadCenter.uploadAsset(
'prefix-private/asset.txt',
createReadStream(fixturePath('asset.txt')),
{
acl: 'private',
}
);

const content = await downloadCenter.downloadAsset(
'prefix-private/asset.txt'
);
expect(content?.toString()).to.contain('content');
});
});

describe('upload / download config', function () {
Expand Down
5 changes: 4 additions & 1 deletion packages/dl-center/src/download-center.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type S3BucketConfig = {

export type UploadAssetOptions = {
contentType?: string;
acl?: string;
};

type S3UploadFunc = (
Expand Down Expand Up @@ -235,8 +236,10 @@ export class DownloadCenter {
throw new Error('s3ObjectKey is required');
}

const acl = options.acl ?? ACL_PUBLIC_READ;

const uploadParams: S3.PutObjectRequest = {
ACL: ACL_PUBLIC_READ,
ACL: acl,
Bucket: this.s3BucketName,
Key: s3ObjectKey,
Body: content,
Expand Down