From 1158771fd6da0f86402ab286524375f750a9a3e2 Mon Sep 17 00:00:00 2001 From: anq83 <75251941+anq83@users.noreply.github.com> Date: Tue, 21 May 2024 16:37:26 +0300 Subject: [PATCH] M2-6497: [Mobile] Add dynamic answer structure to support arbitrary server with GCP and other providers (#767) * M2-6497: [Mobile] Add dynamic answer structure to support arbitrary server with GCP and other providers --------- Co-authored-by: Nalivaiko, Aleksej --- .../lib/services/AnswersUploadService.ts | 4 ++++ src/shared/api/services/fileService.ts | 21 ++++--------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/entities/activity/lib/services/AnswersUploadService.ts b/src/entities/activity/lib/services/AnswersUploadService.ts index 9876de0f6..9505c3138 100644 --- a/src/entities/activity/lib/services/AnswersUploadService.ts +++ b/src/entities/activity/lib/services/AnswersUploadService.ts @@ -156,6 +156,10 @@ class AnswersUploadService implements IAnswersUploadService { `[UploadAnswersService.processFileUpload] Uploading file ${logFileInfo}`, ); + this.logger.log( + `[UploadAnswersService.processFileUpload] Received field names: ${Object.keys(getFieldsDto.fields).toString()}`, + ); + await FileService.uploadAppletFileToS3({ fields: getFieldsDto.fields, fileName: mediaFile.fileName, diff --git a/src/shared/api/services/fileService.ts b/src/shared/api/services/fileService.ts index 6e44e2676..9384a5ab9 100644 --- a/src/shared/api/services/fileService.ts +++ b/src/shared/api/services/fileService.ts @@ -50,13 +50,7 @@ type GetFieldsForFileUploadRequest = { type FieldsForFileUploadDto = { uploadUrl: string; url: string; - fields: { - key: string; - AWSAccessKeyId: string; - 'x-amz-security-token': string; - policy: string; - signature: string; - }; + fields: Record; }; type GetFieldsForFileUploadResponse = @@ -207,19 +201,12 @@ function fileService() { ? request.localUrl : request.localUrl.replace('file://', ''); - data.append('key', request.fields.key); - data.append('AWSAccessKeyId', request.fields.AWSAccessKeyId); + const fieldKeys = Object.keys(request.fields); - if (request.fields['x-amz-security-token']?.length) { - data.append( - 'x-amz-security-token', - request.fields['x-amz-security-token'], - ); + for (const key of fieldKeys) { + data.append(key, request.fields[key]); } - data.append('policy', request.fields.policy); - data.append('signature', request.fields.signature); - data.append('file', { uri: localUrl, name: request.fileName,