diff --git a/kidgirlno6.1-s-8c43f085-e53c-49f2-b9a4-909ee4502cf3.png b/kidgirlno6.1-s-8c43f085-e53c-49f2-b9a4-909ee4502cf3.png new file mode 100644 index 000000000..9a53c71bc Binary files /dev/null and b/kidgirlno6.1-s-8c43f085-e53c-49f2-b9a4-909ee4502cf3.png differ diff --git a/kidgirlno6.2-s-17003d2e-97ec-4f1b-896a-5323e1a4d39a.png b/kidgirlno6.2-s-17003d2e-97ec-4f1b-896a-5323e1a4d39a.png new file mode 100644 index 000000000..addfafa1a Binary files /dev/null and b/kidgirlno6.2-s-17003d2e-97ec-4f1b-896a-5323e1a4d39a.png differ diff --git a/src/features/children/children.controller.ts b/src/features/children/children.controller.ts index 43744c3a1..b9c784776 100644 --- a/src/features/children/children.controller.ts +++ b/src/features/children/children.controller.ts @@ -62,6 +62,7 @@ import { AllUserEntity } from 'src/entities/user.entity'; import { checkIfFileOrDirectoryExists, moveFile } from 'src/utils/file'; import fs from 'fs'; import { CampaignService } from '../campaign/campaign.service'; +import { File } from '@web-std/file'; @ApiTags('Children') @ApiSecurity('flask-access-token') @@ -88,7 +89,7 @@ export class ChildrenController { @UseInterceptors(FileInterceptor('voiceFile', voiceStorage)) async approvePreregister( @Req() req: Request, - @UploadedFile() voiceFile, + @UploadedFile() voiceFile: Express.Multer.File, @Param('id') id: string, @Body(ValidateChildTsPipe) body: CreateFlaskChildDto, ) { @@ -132,12 +133,20 @@ export class ChildrenController { `${preRegister.sleptUrl}`, ); + const fileBuffer = await fs.promises.readFile( + `uploads/children/voices/${voiceFile.filename}`, + ); + + const file = new File([fileBuffer], `${voiceFile.filename}`, { + type: voiceFile.mimetype, + }); + const formData = new FormData(); formData.append('ngo_id', String(preRegister.flaskNgoId)); formData.append('sw_id', String(preRegister.flaskSwId)); formData.append('awakeAvatarUrl', awakeFile); formData.append('sleptAvatarUrl', sleptFile); - formData.append('voiceUrl', voiceFile); + formData.append('voiceUrl', file); formData.append( 'gender', String(preRegister.sex === SexEnum.MALE ? true : false), diff --git a/src/features/download/download.service.ts b/src/features/download/download.service.ts index 888d464b6..f84fcb037 100644 --- a/src/features/download/download.service.ts +++ b/src/features/download/download.service.ts @@ -116,6 +116,7 @@ export class DownloadService { console.log('Downloaded !! ' + name); return file; } catch (e) { + console.log(e); throw new WalletExceptionFilter(e.status, e.message); } } diff --git a/src/storage/voiceStorage.ts b/src/storage/voiceStorage.ts index da3274107..ee252ca47 100644 --- a/src/storage/voiceStorage.ts +++ b/src/storage/voiceStorage.ts @@ -3,12 +3,13 @@ import { uuid } from 'uuidv4'; import path from 'path'; export const voiceStorage = { - storage: diskStorage({ - destination: './uploads/children/voices', - filename: (req, file, cb) => { - const fileName: string = path.parse(file.originalname).name.replace(/\s/g, '') + uuid() // unique id - const extension: string = path.parse(file.originalname).ext - return cb(null, `${fileName}${extension}`) - } - }) -} \ No newline at end of file + storage: diskStorage({ + destination: './uploads/children/voices', + filename: (req, file, cb) => { + const fileName: string = + path.parse(file.originalname).name.replace(/\s/g, '') + uuid(); // unique id + const extension: string = path.parse(file.originalname).ext; + return cb(null, `${fileName}${extension}`); + }, + }), +};