File event not invoke
See original GitHub issueI have a simple route handler that accepts file uploads. However, the following code doesn’t work. The route gets called but file event is not fired. I’ve been checking my code against examples and couldn’t find what causing this. I appreciate much anyone could point out what causing this.
restify = require('restify'),
BusBoy = require('busboy');
request = require('request');
session = require('restify-session')({
debug : false,
ttl : 200 // Time to live in seconds
});
server = restify.createServer();
server.post('/files', uploadFile);
server.listen(8082);
function uploadFile(req, res, next) {
var fileStream = new BusBoy({ headers: req.headers });
req.pipe(fileStream);
fileStream.on('file', function(fieldname, file, filename, encoding, mimetype) {
console.log('File [' + fieldname + ']: filename: ' + filename + ', encoding: ' + encoding + ', mimetype: ' + mimetype);
res.end();
});
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
HTML input file selection event not firing upon selecting the ...
If I 'open' the same file again in an desktop application, it is usually reloaded, or if some action is done with the...
Read more >Troubleshoot invocation issues in Lambda
Invocation errors can be caused by issues with request parameters, event structure, function settings, user permissions, resource permissions, or limits. If you ...
Read more >Introduction to events - Learn web development | MDN
Events are actions or occurrences that happen in the system you are programming, which the system tells you about so your code can...
Read more >Standard .NET event patterns | Microsoft Learn
Empty that you should use to denote that your event does not contain any additional information ... Invoke(this, new FileFoundArgs(file)); } ...
Read more >fileevent (n) - Tcl
If the script argument is specified as an empty string then the event handler is deleted, so that no script will be invoked....
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
A code snippet from above really helped me out. I’m sending an audiofile from Faraday as a multipart post.
And the Rails/Ruby:
Thank you for your advice, @mscdex. I ended up using the busboy “finish” listener quite successfully here. I changed the var names a bit from before.