Attach() should put files on request.files?
See original GitHub issueHello, this is more a doubt than a issue.
I’m using the method attach() to simulate a file upload to a express middleware. I was expecting that the request.files would be filled with the information of the attached file, but instead I’m receiving an undefined variable on request.
Am I doing something wrong?
request(app)
.post('/test')
.attach('image', __dirname + '/fixtures/fatcat.jpeg')
.expect('Content-Type', /json/)
.expect('Content-Length', '15')
.expect(201)
.end(function(err, res){
if (err) throw err;
done();
});
middleware
return function handler(req, res, next) {
console.log(req.files); // returns undefined :(
}
Thanks in advance.
Issue Analytics
- State:
- Created 11 years ago
- Comments:15 (1 by maintainers)
Top Results From Across the Web
Attach() should put files on request.files? · Issue #47 - GitHub
Hello, this is more a doubt than a issue. I'm using the method attach() to simulate a file upload to a express middleware....
Read more >javascript - how to attach a file to request so that it shows up ...
The way I have found examples are: const file = fs.readFileSync(filePath) const formData = new FormData() formData.append('userId', ...
Read more >Create a file request - Microsoft Support
Click Select files, browse to the appropriate folder, and select the file being requested. If you need to add additional files, select Add...
Read more >Request Files - FastAPI
You don't have to use File() in the default value of the parameter. · It uses a "spooled" file: · This means that...
Read more >Uploading Files — Flask Documentation (2.2.x)
Let's start with a very basic application that uploads a file to a specific upload folder and displays a file to the user....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
my solution was to use
.field()
s along with.attach()
(if i remember correctly i even got a warning sometime that.send()
and.attach()
don’t work together)i’ve encountered so many issues with multer and multipart form data, so i’d rather handle
base64
via json