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.

File upload (fastify)

See original GitHub issue

I’m submitting a…


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request (new chapter/page)
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Expected behavior

https://github.com/nestjs/nest/issues/719

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


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

Others:

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

17reactions
Luby1917commented, Apr 11, 2019

Just tried to “adapt” the fastify-multipart 😃 Thanks to @reyx for pointing out to the right direction

main.ts

  const fAdapt = new FastifyAdapter()
  fAdapt.register(require('fastify-multipart'))

  const app = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    fAdapt,
  );

file.controller.ts

import * as fs from "fs";
import * as pump from "pump";
import { Controller, Post, Req, Res } from '@nestjs/common';

@Controller('files')
export class FilesController {
  @Post()
	upload(@Req() req, @Res() reply): void {		
		const mp = req.multipart(handler, function (err) {
			console.log('upload completed')
			reply.code(200).send()
		})
		function handler (field, file, filename, encoding, mimetype) {				
			pump(file, fs.createWriteStream('file')) //File path
		}
	}
}


2reactions
reyxcommented, Sep 9, 2018

Maybe this module can be adapted: https://github.com/fastify/fastify-multipart

Read more comments on GitHub >

github_iconTop Results From Across the Web

fastify-file-upload
file upload plugin for Fastify. Latest version: 4.0.0, last published: 8 months ago. Start using fastify-file-upload in your project by ...
Read more >
How to handle Node.js file uploads with Fastify
In the following sections, you'll create a Fastify project, set up a file upload plugin, create an /upload route that can handle multiple...
Read more >
Fastify Multipart File Upload
Fastify manages multipart form data to save uploaded files. Upload your files using axios or fetch.
Read more >
huangang/fastify-file-upload
Fastify plugin for uploading files. Contribute to huangang/fastify-file-upload development by creating an account on GitHub.
Read more >
Upload files using multipart with Fastify and NestJS
Upload files using multipart with Fastify and NestJS · main.ts. Now we can use the package. Go to your controller. · tasks.controller.ts.
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