multer

Multer upload multiple files from different inputs

99封情书 提交于 2020-01-06 07:23:42
问题 I'm rather new to multer/node/express/mongoose/... and I'm currently trying to upload multiple files from different inputs that have the same name (I generate the inputs using reactjs). Here's my React front-end: onSubmit = (e) => { e.preventDefault(); const {imges} = this.state; let formData = new FormData(); formData.append('imges', imges); axios.post('newuser', formData) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); }

Multer upload multiple files from different inputs

馋奶兔 提交于 2020-01-06 07:23:28
问题 I'm rather new to multer/node/express/mongoose/... and I'm currently trying to upload multiple files from different inputs that have the same name (I generate the inputs using reactjs). Here's my React front-end: onSubmit = (e) => { e.preventDefault(); const {imges} = this.state; let formData = new FormData(); formData.append('imges', imges); axios.post('newuser', formData) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); }

How do i produce multer error message in my postman

人走茶凉 提交于 2020-01-06 04:30:12
问题 Im trying to res.status.send a multer error message to postman when my file image exceeds 1MB. But when i try to run my code it only gives me this entire chunk of error message. I just want to get the error message itself(LIMIT_FILE_SIZE).Is there any way to achieve this? IMAGE HERE My current app.js: var multer = require('multer'); var storage = multer.diskStorage({ destination: function(req, file, callback) { callback(null, './uploads'); }, filename: function(req, file, callback) { callback

ExpressJS Multer: Upload image to server

我怕爱的太早我们不能终老 提交于 2020-01-04 19:47:23
问题 I'm newer with Node.js and Express.js. I want to upload first a image into the server (directory: uploads/spots), and then (synchronous) upload the rest of form data in MongoDB. I'm using REST (Method Post) app.route('/spots').post(users.requiresLogin, spots.create); and I'm using Multer for updating the image into the server, and works. app.use(multer( { dest: './public/uploads/spots', onFileUploadStart: function (file) { var imagePath = file.path; gm(imagePath).resize(850, 850).quality(70)

express multer Cannot read property 'profileimage' of undefined

无人久伴 提交于 2020-01-04 03:49:08
问题 I am trying to submit a form which has a file input within it with a name of profileimage , i am using express 4, express generator and multer. In my app.js I added multer like so: var multer = require('multer'); var upload = multer({ dest: './uploads' }); The tutorial i am following actually sets up multer like so (after requiring it) but it gives me an error: app.use(multer({dest: './uploads'})); And in my routes folder inside the respective file I have the following: router.post('/register

Angular shows 404 not found in the frontend when image has been uploaded but shows image if angular build has done

旧城冷巷雨未停 提交于 2020-01-03 05:55:24
问题 I am using angular 5 with Node js, express and mongodb to upload images with some data. All the data are saving into mongodb without any issue but when I am trying to show the uploaded images it is showing 404 not found even the image is still exist in the uploads folder. I have even tried to hardcode the path with the image name but still its showing 404 error. But if I make some change in the angular code(which builts angular after some chnages) or built the angular it shows the image. I

Combine multer and tinypng API in node

独自空忆成欢 提交于 2020-01-02 17:50:13
问题 does anyone know how to use tinyPNG's API with multer? The docs seem deceptively simple: var source = tinify.fromFile("unoptimized.jpg"); source.toFile("optimized.jpg"); though there's no clear indication of where this is meant to go, especially in something as convoluted as this: var storage = multer.diskStorage( { destination: function (req, file, callback) { callback(null, './uploads'); }, filename: function (req, file, callback) { //use date to guarantee name uniqueness callback(null,

transfer files between two node.js servers over http

跟風遠走 提交于 2020-01-02 06:57:09
问题 I have two node.js/express servers that communicate with each other with http. server A is also communicates with the browser and can handle file upload requests. When file is uploaded to server A i want to transfer it as is to server B for further processing. what is the best way to do so? preferably with request-promise module which is what i'm using for communication between the two servers. This is what i got so far, but i am unable to transfer the file between the servers, the file is

Get image sent from post in node.js

流过昼夜 提交于 2020-01-02 06:32:20
问题 I need to use python to send an image through post and then download it on the node.js server side. Python code: import requests from PIL import Image import json url = 'http://127.0.0.1:8080/ay' files = {'file': open('image.jpg', 'rb')} r = requests.post(url, data = files) Node.js code: var app = express(); app.use(bodyparser.json({ limit: '50mb' })); app.use(bodyparser.urlencoded({ limit: '50mb', extended: true })); app.post('/ay', function(req, res) { var base64Data = req.body.file require

Uploading large file to NodeJS webserver

五迷三道 提交于 2020-01-01 03:13:06
问题 I am serving up my web application using NodeJS server (ExpressJS) currently. One of the new requirements is for the users to be able to upload large videos (potentially in gigs) to the server. They will later then be able to download them again. Could I achieve this with the current stack? I came across tutorials using Multer JS with "multipart/form-data" specified by the front-end. If I use this, would my Express be able to serve up other HTTP requests while writing a giant single video