[BUG] storage._handleFile is not a function

See original GitHub issue

#Information

I set option @ServerSetings

    {
        multer: {
        storage: handleStorage(),
    }

With handleStore function will return multer.StorageEngine, but I when upload is error and crash node

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
Romakitacommented, Mar 30, 2020

Fixed 😃

1reaction
chiqui3dcommented, Mar 28, 2020

The same thing happened to me, I had to pass the storage function directly to the controller, because as a global function it doesn’t work. I guess it should be fixed, while you can do it on the controller:

import { MulterOptions, MultipartFile } from '@tsed/multipartfiles'
import { diskStorage } from 'multer';

const storage = diskStorage({
  destination: function (req, file, cb) {
    cb(null, './public/uploads/profiles')
  },
  filename: function (req, file, cb) {
    cb(null, file.originalname)
  }
});

  @Post('/upload/:id')
  @Description('Upload image profile by user ID')
  @MulterOptions({ storage: storage })
  async upload (@MultipartFile('image') image, @PathParams('id') id): Promise<any> {
    const user = await this.userRepository.findOne(id);
    if (!user) {
      throw new NotFound('Not user found')
    }
    user.image = '/uploads/profiles/' + image.originalname;
    return this.userRepository.save(user);
 
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: storage._handleFile is not a function · Issue #702
TypeError : storage._handleFile is not a ... mfu.html. I am getting the error of storage._handleFile is not a Function as shown below
Read more >
TypeError: storage._handleFile is not a function - Stack Overflow
Just multer because using that you can still upload the image but not to the database. Instead you can store the image into...
Read more >
TypeError: storage._handleFile is not a function
TypeError : storage._handleFile is not a function. #node #javascript #react. require('dotenv') const multer = require('multer')
Read more >
Typeerror: Storage._Handlefile Is Not A Function - ADocLib
Typeerror: Storage._Handlefile Is Not A Function. Now go to Visual studio code and run the Reactjs project by using 'npm start' you can...
Read more >
TypeError: storage._handleFile is not a function - DevPress
TypeError : storage._handleFile is not a function. require('dotenv') const multer = require('multer') const sftpMulter ...
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