Skip to content
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