I'm using nestjs, and Im trying to upload multiple files. Each file can also contain sound (which is also a file). This is how it looks on postman. Request
and this is how the request looks like. uploadedfiles
This is what the code looks like:
@ApiConsumes('multipart/form-data')
@ApiMultiFile()
@Serialize(MemoryGetOneResponseDto)
@UseInterceptors(AnyFilesInterceptor())
async create(
@CurrentUser() user: EUser,
@UploadedFiles() files: Express.Multer.File[],
@Request() req,
// @Body() dto: DTO
) {
console.log(files);
I'm trying to link the files with sounds somehow, probably something like this:
[
{
fieldname: 'files',
originalname: 'image.jpeg',
encoding: '7bit',
mimetype: 'image/jpeg',
buffer: <Buffer>,
size: 100064,
sounds: {
fieldname: 'files[0][sounds]',
originalname: 'sound.mp3',
encoding: '7bit',
mimetype: 'audio/mpeg',
buffer: <Buffer>,
size: 816132
}
}...
]
but i got this:
[
{
fieldname: 'files',
originalname: 'image.jpeg',
encoding: '7bit',
mimetype: 'image/jpeg',
buffer: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff db 00 84 00 08 06 06 07 06 05 08 07 07 07 09 09 08 0a 0c 15 0e 0c 0b 0b 0c 19 12 13 0f ... 100014 more bytes>,
size: 100064
},
{
fieldname: 'files',
originalname: 'logo.png',
encoding: '7bit',
mimetype: 'image/png',
buffer: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 78 00 00 00 2b 08 03 00 00 00 84 a0 bc b9 00 00 01 50 50 4c 54 45 47 70 4c 25 22 23 3f 3d 3d ... 1930 more bytes>,
size: 1980
},
{
fieldname: 'files[0][sounds]',
originalname: 'sound.mp3',
encoding: '7bit',
mimetype: 'audio/mpeg',
buffer: <Buffer 49 44 33 04 00 00 00 14 60 64 54 58 58 58 00 00 00 12 00 00 03 6d 61 6a 6f 72 5f 62 72 61 6e 64 00 64 61 73 68 00 54 58 58 58 00 00 00 11 00 00 03 6d ... 816082 more bytes>,
size: 816132
}
]
Via Active questions tagged javascript - Stack Overflow https://ift.tt/y561Zj0
Comments
Post a Comment