daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Jan 15th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. req.uploadFileName is undefined.
  2. console.log('Upload file...' + req.file); //undefined
  3. console.log('Upload file...' + req.files); //undefined
  4. console.log('Upload uploadFileName...' + req.uploadFileName); //undefined
  5. console.log('Upload  body' + req.body) //undefined
  6.    
  7. export const uploadFile = (req, res, next) => {
  8.     console.log('Upload file...' + req.file);
  9.     console.log('Upload file...' + req.files);
  10.     console.log('Upload uploadFileName...' + req.uploadFileName);
  11.     console.log('Upload  body' + req.body);
  12.  
  13.     let file = req.uploadFileName;
  14.     console.log('Upload fileName' + req.body.uploadFileName);;
  15.     if (file) {
  16.         uploadImageToStorage(file).then((fileURL) => {
  17.             res.json({
  18.                 status: 'success',
  19.                 fileURL: fileURL
  20.             });
  21.         }).catch((error) => {
  22.             console.error(error);
  23.             next('failed to upload file ', error)
  24.         });
  25.     } else {
  26.         console.error('failed to upload file ', file);
  27.         next('failed to upload file ', file)
  28.     }
  29. };
  30.  
  31. export const getUpload = () => {
  32.     // no larger than 5mb, you can change as needed.
  33.     const multer = Multer({
  34.         storage: Multer.memoryStorage(),
  35.         limits: {
  36.             fileSize: 5 * 1024 * 1024;
  37.         }
  38.  
  39.     });
  40.     return multer.single('uploadFileName')
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top