question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@UploadedFile not working with @Body

See original GitHub issue

Bug Report

So the intention is pretty simple here. want to upload image and store the image url in collection

Current behavior

Input Code

  @Post()
  @UsePipes(ValidationPipe)
  @UseInterceptors(FileInterceptor('additional_image'))
  async createCourse(@UploadedFile() files, @Body() createCourseDto: CreateCourseDto
                    ) {
                      console.log('Files::', files);
                      console.log('createCourseDto::', createCourseDto);
  
  } 

Expected behavior

Possible Solution

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:
so this code doesn't upload image and provide any url. what's the nest way to achieve this?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nartccommented, Dec 15, 2019

@iaakash I don’t know whether you’ve solved the issue but you need to set properties: { 'additional_image': {...} } instead of properties: { file: {...} }

0reactions
lock[bot]commented, Jun 24, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FileInterceptor and Body Issue in NestJS (upload a file and ...
I have the following controller : createCollection( @UploadedFile() file, @Body ...
Read more >
File uploads (profile image, simple, resumable uploads)
The client will not know, nor should it care, where precisely an uploaded file will go on the service (nor what key or...
Read more >
File Uploads - Django documentation
Here's a common way you might handle an uploaded file: ... Looping over UploadedFile.chunks() instead of using read() ensures that large files don't ......
Read more >
Uploading files using POST forms - Slim Framework
Files that are uploaded using forms in POST requests can be retrieved with the getUploadedFiles method of the Request object. When uploading files...
Read more >
Upload files in ASP.NET Core - Microsoft Learn
When files shouldn't be overwritten by an uploaded file with the same name, ... Form does not buffer the entire request body (BufferBody), ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found