Skip to content

Commit 8b115b0

Browse files
committed
fix: empty file tags cause upload error for some providers
DigitalOcean and Linode object storage solutions do not accept `tags` option while uploading a file. Previously, tags option was set to default empty object. Now, we do not include it if it is empty.
1 parent d144819 commit 8b115b0

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/Routers/FilesRouter.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,26 @@ export class FilesRouter {
166166
// update fileSize
167167
const bufferData = Buffer.from(fileObject.file._data, 'base64');
168168
fileObject.fileSize = Buffer.byteLength(bufferData);
169+
// prepare file options
170+
const fileTags = fileObject.file._tags;
171+
let fileOptions = {
172+
metadata: fileObject.file._metadata,
173+
};
174+
if (Object.keys(fileTags).length > 0) {
175+
// some s3-compatible providers (DigitalOcean, Linode) do not accept tags
176+
// so we do not include the tags option if it is empty.
177+
fileOptions = {
178+
...fileOptions,
179+
tags: fileTags,
180+
};
181+
}
169182
// save file
170183
const createFileResult = await filesController.createFile(
171184
config,
172185
fileObject.file._name,
173186
bufferData,
174187
fileObject.file._source.type,
175-
{
176-
tags: fileObject.file._tags,
177-
metadata: fileObject.file._metadata,
178-
}
188+
fileOptions
179189
);
180190
// update file with new data
181191
fileObject.file._name = createFileResult.name;

0 commit comments

Comments
 (0)