question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use with form upload and express 4?

See original GitHub issue

I’m trying to use this to upload a file via a form post. It worked fine using express 3 but with express 4 the request.files object is empty. There have been suggestions online to use multer or busboy but I cant figure out how to implement them with s3-uploader. Here is a copy of upload function

exports.upload = function (req, response) {
    var filepath = req.files.image.path;
    var s3config = require('../config/aws.json');
    var client = new Upload('bucket-name', {aws: s3config})
    client.upload(filepath, {}, function (err, versions, meta) {
    });
}

req.files object is always empty. Any suggestions on how I get that object to contain the file info?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
anthonyringoetcommented, Aug 31, 2016

It can work with express v4 but you will need a middleware for handling multipart/form-data. (like multer). It will populate req.files/req.file. Can you add this and try again?

0reactions
anthonyringoetcommented, Sep 1, 2016

If something pops up, feel free to open this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multer: Easily upload files with Node.js and Express
Multer is a Node.js middleware for handling multipart/form-data that makes the otherwise painstaking process of uploading files in Node.js ...
Read more >
How to Handle File Uploads from Node.js to Express - Twilio
Learn how to upload files by posting multipart/form-data from Node.js to Express with the help of the FormData and Multer libraries.
Read more >
Express Tutorial Part 6: Working with forms - MDN Web Docs
Express itself doesn't provide any specific support for form handling operations, but it can use middleware to process POST and GET parameters ...
Read more >
How to Handle File Upload with Node and Express 4.0 | e-Zest
The first, get the method in the router caters to the browser's request to show the page and paints our uploadPage, with upload...
Read more >
How to upload files in Node.js and Express
A comprehensive guide to learning how to upload single and multiple files in Node.js.
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