Skip to content

Don't send tags during upload if none are in options #135

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

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class S3Adapter {
if (options.metadata && typeof options.metadata === 'object') {
params.Metadata = options.metadata;
}
if (options.tags && typeof options.tags === 'object') {
if (options.tags && typeof options.tags === 'object' && Object.keys(options.tags).length > 0) {
const serializedTags = serialize(options.tags);
params.Tagging = serializedTags;
}
Expand Down
15 changes: 15 additions & 0 deletions spec/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,21 @@ describe('S3Adapter tests', () => {
await s3.createFile(fileName, 'hello world', 'text/utf8', { tags });
});

it('should not send tags to s3 upload function, where tags object is empty', async () => {
const s3 = makeS3Adapter(options);
s3._s3Client.upload = (params, callback) => {
const { Tagging } = params;
expect(Tagging).toBeUndefined();
const data = {
Body: Buffer.from('hello world', 'utf8'),
};
callback(null, data);
};
const fileName = 'randomFileName.txt';
const tags = { };
await s3.createFile(fileName, 'hello world', 'text/utf8', { tags });
});

it('should save a file with proper ACL with direct access', async () => {
// Create adapter
options.directAccess = true;
Expand Down