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

ValueError: X has 10 features, but LinearRegression is expecting 1 features as input

So, I am trying to predict the model but its throwing error like it has 10 features but it expacts only 1. So I am confused can anyone help me with it? more importantly its not working for me when my friend runs it. It works perfectly fine dose anyone know the reason about it? cv = KFold(n_splits = 10) all_loss = [] for i in range(9): # 1st for loop over polynomial orders poly_order = i X_train = make_polynomial(x, poly_order) loss_at_order = [] # initiate a set to collect loss for CV for train_index, test_index in cv.split(X_train): print('TRAIN:', train_index, 'TEST:', test_index) X_train_cv, X_test_cv = X_train[train_index], X_test[test_index] t_train_cv, t_test_cv = t[train_index], t[test_index] reg.fit(X_train_cv, t_train_cv) loss_at_order.append(np.mean((t_test_cv - reg.predict(X_test_cv))**2)) # collect loss at fold all_loss.append(np.mean(loss_at_order)) # collect loss at order plt.plot(np.log(al...

Sorting large arrays of big numeric stings

I was solving bigSorting() problem from hackerrank: Consider an array of numeric strings where each string is a positive number with anywhere from to digits. Sort the array's elements in non-decreasing, or ascending order of their integer values and return the sorted array. I know it works as follows: def bigSorting(unsorted): return sorted(unsorted, key=int) But I didnt guess this approach earlier. Initially I tried below: def bigSorting(unsorted): int_unsorted = [int(i) for i in unsorted] int_sorted = sorted(int_unsorted) return [str(i) for i in int_sorted] However, for some of the test cases, it was showing time limit exceeded. Why is it so? PS: I dont know exactly what those test cases were as hacker rank does not reveal all test cases. source https://stackoverflow.com/questions/73007397/sorting-large-arrays-of-big-numeric-stings

How to load Javascript with imported modules?

I am trying to import modules from tensorflowjs, and below is my code. test.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title </head> <body> <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@2.0.0/dist/tf.min.js"></script> <script type="module" src="./test.js"></script> </body> </html> test.js import * as tf from "./node_modules/@tensorflow/tfjs"; import {loadGraphModel} from "./node_modules/@tensorflow/tfjs-converter"; const MODEL_URL = './model.json'; const model = await loadGraphModel(MODEL_URL); const cat = document.getElementById('cat'); model.execute(tf.browser.fromPixels(cat)); Besides, I run the server using python -m http.server in my command prompt(Windows 10), and this is the error prompt in the console log of my browser: Failed to loa...