multer

How to cascade a file uploaded in react to node Js and then to another API, all through HTTP calls using axios?

时光总嘲笑我的痴心妄想 提交于 2020-08-19 10:54:07
问题 Let me explain my question in detail. React UI is uploading a file using axios post by creating a form-data to Node Js API. In Node Js API, using Multer received the file. const multer = require('multer'); const upload = multer({ storage: multer.memoryStorage() }); . . . router.post('/fileUpload/:customer/', upload.single('file'), async (req, res) => { try { const result = await RequestService.sendFile( req.file, req.params.customer, ); if (result.status === 200 || 204) { } else { } } catch

How can we send data in MySQL when the form has set to enctype=“multipart/form-data” in node.js?

安稳与你 提交于 2020-08-17 12:12:32
问题 This enctype="multipart/form-data" blocking me from sending my data to mysql but it is a must for multer to work. I'm trying to store the image filename to database while the file will store to my project directory ./uploads using multer framework. I've tried different queries but nothing happen. I'm hoping for you guys which have faced the same issue like mine please take a little of your time. Thank you in advance. <form class="add-music-form" action="/save" method="POST" enctype="multipart