fix: empty file tags cause upload error for some providers (#7300)
* 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. * chore: add tests for saving a file with/without tags * chore: update file tags handling to make tests pass * chore: refactor file tag tests * chore: update file tag tests * chore: update changelog * chore: update changelog entry * chore: remove duplicated changelog entry
This commit is contained in:
committed by
GitHub
parent
626352d594
commit
4d167026ae
@@ -166,16 +166,22 @@ export class FilesRouter {
|
||||
// update fileSize
|
||||
const bufferData = Buffer.from(fileObject.file._data, 'base64');
|
||||
fileObject.fileSize = Buffer.byteLength(bufferData);
|
||||
// prepare file options
|
||||
const fileOptions = {
|
||||
metadata: fileObject.file._metadata,
|
||||
};
|
||||
// some s3-compatible providers (DigitalOcean, Linode) do not accept tags
|
||||
// so we do not include the tags option if it is empty.
|
||||
const fileTags =
|
||||
Object.keys(fileObject.file._tags).length > 0 ? { tags: fileObject.file._tags } : {};
|
||||
Object.assign(fileOptions, fileTags);
|
||||
// save file
|
||||
const createFileResult = await filesController.createFile(
|
||||
config,
|
||||
fileObject.file._name,
|
||||
bufferData,
|
||||
fileObject.file._source.type,
|
||||
{
|
||||
tags: fileObject.file._tags,
|
||||
metadata: fileObject.file._metadata,
|
||||
}
|
||||
fileOptions
|
||||
);
|
||||
// update file with new data
|
||||
fileObject.file._name = createFileResult.name;
|
||||
|
||||
Reference in New Issue
Block a user