Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: req.pipe is not a function when multer upload #80

Open
tablecell opened this issue Dec 3, 2019 · 3 comments
Open

TypeError: req.pipe is not a function when multer upload #80

tablecell opened this issue Dec 3, 2019 · 3 comments

Comments

@tablecell
Copy link

tablecell commented Dec 3, 2019

app.js

var server = require('diet')
var multer  = require('multer')
var upload = multer({ dest: 'uploaded/' });

var app = server();
app.listen(3000);
app.get('/', function($){ 
$.header('content-type', 'text/html');
  $.end('<form action="/upload" enctype="multipart/form-data" method="post"><input type="file" name="upfile" id="f" /><input type="submit" value="upload" /></form>');

})

app.post('/upload', upload.single('upfile'),function($){
	console.log($.request.files);
 	$.end('multipart: ' + $.multipart)
})

node app.js

curl -F "upfile=@xxx.jpg" http://localhost:3000/upload

@adamhalasz
Copy link
Owner

Thanks for the report. Will look into this soon. Probably just have to add request.pipe to $.req

@MrBigDog2U
Copy link

MrBigDog2U commented Jul 29, 2020

I am seeing this exact same behavior. Has any resolution been communicated? I looked at trying to copy request.pipe but, from what I can tell, request.pipe is also undefined.

@tablecell
Copy link
Author

tablecell commented Aug 27, 2020

formidable works ok

app.post('/upload', function upload($){
	var form = new formidable.IncomingForm();
 	form.parse($.request, function(err, fields, files) {
                console.log(fields);
                console.log($.body);
                console.log($.params);
		$.data.file =files['upfile']['path'];
  	        //    $.return();
		$.end('multipart: ' + $.data.file )
	});
});

use formidable upload works ok but console.log( fields) is empty $.body) ,$.params is also empty

form page is

 $.end('<form action="/upload" enctype="multipart/form-data" method="post"><input  name+"user" id="u" /><input type="file" name="upfile" id="f" /><input type="submit" value="upload" /></form>');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants