Skip to content

Commit

Permalink
M2-6497: [Mobile] Add dynamic answer structure to support arbitrary s…
Browse files Browse the repository at this point in the history
…erver 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 <[email protected]>
  • Loading branch information
anq83 and AlekseyNalivaiko authored May 21, 2024
1 parent 36bd954 commit 1158771
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
4 changes: 4 additions & 0 deletions src/entities/activity/lib/services/AnswersUploadService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 4 additions & 17 deletions src/shared/api/services/fileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>;
};

type GetFieldsForFileUploadResponse =
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1158771

Please sign in to comment.