Skip to main content

Nestjs: files with details in them?

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

Popular posts from this blog

How to show number of registered users in Laravel based on usertype?

i'm trying to display data from the database in the admin dashboard i used this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count(); echo $users; ?> and i have successfully get the correct data from the database but what if i want to display a specific data for example in this user table there is "usertype" that specify if the user is normal user or admin i want to user the same code above but to display a specific usertype i tried this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count()->WHERE usertype =admin; echo $users; ?> but it didn't work, what am i doing wrong? source https://stackoverflow.com/questions/68199726/how-to-show-number-of-registered-users-in-laravel-based-on-usertype

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console...

How to split a rinex file if I need 24 hours data

Trying to divide rinex file using the command gfzrnx but getting this error. While doing that getting this error msg 'gfzrnx' is not recognized as an internal or external command Trying to split rinex file using the command gfzrnx. also install'gfzrnx'. my doubt is I need to run this program in 'gfzrnx' or in 'cmdprompt'. I am expecting a rinex file with 24 hrs or 1 day data.I Have 48 hrs data in RINEX format. Please help me to solve this issue. source https://stackoverflow.com/questions/75385367/how-to-split-a-rinex-file-if-i-need-24-hours-data