Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Upload local files nestjs

Copy and paste this decorator into the controller.

Check that the files directory has been created.


  @UseInterceptors(
    FileInterceptor('file', {
      storage: diskStorage({
        destination: './files',
        filename: (req, file, cb) => {
          const fileNameSplit = file.originalname.split('.');
          const fileExt = fileNameSplit[fileNameSplit.length - 1];
          cb(null, `${Date.now()}.${fileExt}`);
        },
      }),
    }),
  )
  @Post("/upload")
  create(
    @UploadedFile() file: Express.Multer.File,
  ) {
 	console.log(file)
  }
Comment

file upload nest

$ npm i -D @types/multer
Comment

PREVIOUS NEXT
Code Example
Javascript :: switch variables javascript 
Javascript :: react carousel 
Javascript :: file_get_contents in javascript 
Javascript :: react doc viewer 
Javascript :: filter in javascipt 
Javascript :: react snack bar 
Javascript :: disable textbox on plumsail 
Javascript :: jquery get id of 3rd parent 
Javascript :: django pointfield json example 
Javascript :: require cycle disable warning react native 
Javascript :: browser support 
Javascript :: hash url owl carousel example 
Javascript :: async function javascript dec 
Javascript :: javascript get all elements of an id 
Javascript :: how to fill html datalist with array values in javascript 
Javascript :: node redirect 
Javascript :: install svelte router 
Javascript :: string contains js 
Javascript :: react import coreui icons 
Javascript :: flutter local json storage 
Javascript :: react testing library increase debug length 
Javascript :: js insert after element 
Javascript :: set cookie in javascript 
Javascript :: chai async test 
Javascript :: player.filter 
Javascript :: javascript download file 
Javascript :: identity-obj-proxy not working 
Javascript :: remove property from object javascript 
Javascript :: jquery deparam 
Javascript :: dart how to convert json to x-www-form-urlencoded 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =