diff --git a/api/src/attachment/services/attachment.service.ts b/api/src/attachment/services/attachment.service.ts index 821682fc..bf0674f1 100644 --- a/api/src/attachment/services/attachment.service.ts +++ b/api/src/attachment/services/attachment.service.ts @@ -61,7 +61,7 @@ export class AttachmentService extends BaseService { const storageHelper = await this.helperService.getDefaultHelper( HelperType.STORAGE, ); - return storageHelper.download(attachment); + return await storageHelper.download(attachment); } /** @@ -74,7 +74,7 @@ export class AttachmentService extends BaseService { const storageHelper = await this.helperService.getDefaultHelper( HelperType.STORAGE, ); - return storageHelper.readAsBuffer(attachment); + return await storageHelper.readAsBuffer(attachment); } /** diff --git a/api/src/migration/migrations/1735836154221-v-2-2-0.migration.ts b/api/src/migration/migrations/1735836154221-v-2-2-0.migration.ts index 60d6a1a5..c7753857 100644 --- a/api/src/migration/migrations/1735836154221-v-2-2-0.migration.ts +++ b/api/src/migration/migrations/1735836154221-v-2-2-0.migration.ts @@ -775,20 +775,29 @@ const migrateAndPopulateAttachmentMessages = async ({ const addDefaultStorageHelper = async ({ logger }: MigrationServices) => { const SettingModel = mongoose.model(Setting.name, settingSchema); try { - await SettingModel.create({ - group: 'chatbot_settings', - label: 'default_storage_helper', - value: 'local-storage-helper', - type: SettingType.select, - config: { - multiple: false, - allowCreate: false, - entity: 'Helper', - idKey: 'name', - labelKey: 'name', + await SettingModel.updateOne( + { + group: 'chatbot_settings', + label: 'default_storage_helper', }, - weight: 2, - }); + { + group: 'chatbot_settings', + label: 'default_storage_helper', + value: 'local-storage-helper', + type: SettingType.select, + config: { + multiple: false, + allowCreate: false, + entity: 'Helper', + idKey: 'name', + labelKey: 'name', + }, + weight: 2, + }, + { + upsert: true, + }, + ); logger.log('Successfuly added the default local storage helper setting'); } catch (err) { logger.error('Unable to add the default local storage helper setting');