{"action":"created","issue":{"url":"https://api.github.com/repos/expressjs/multer/issues/72","labels_url":"https://api.github.com/repos/expressjs/multer/issues/72/labels{/name}","comments_url":"https://api.github.com/repos/expressjs/multer/issues/72/comments","events_url":"https://api.github.com/repos/expressjs/multer/issues/72/events","html_url":"https://github.com/expressjs/multer/issues/72","id":47261544,"number":72,"title":"No simple way to tell the client if an error occured","user":{"login":"james147","id":171232,"avatar_url":"https://avatars.githubusercontent.com/u/171232?v=3","gravatar_id":"","url":"https://api.github.com/users/james147","html_url":"https://github.com/james147","followers_url":"https://api.github.com/users/james147/followers","following_url":"https://api.github.com/users/james147/following{/other_user}","gists_url":"https://api.github.com/users/james147/gists{/gist_id}","starred_url":"https://api.github.com/users/james147/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/james147/subscriptions","organizations_url":"https://api.github.com/users/james147/orgs","repos_url":"https://api.github.com/users/james147/repos","events_url":"https://api.github.com/users/james147/events{/privacy}","received_events_url":"https://api.github.com/users/james147/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2014-10-30T12:01:17Z","updated_at":"2015-07-18T18:32:16Z","closed_at":"2015-07-18T18:32:16Z","body":"All of the error handling functions, `onFileSizeLimit`, `onError` etc... have no way of either telling the client that an error has happened or passing the fact an error happened to the next middle ware:\r\n\r\n```\r\n  router.use('/uploads', multer({\r\n    dest: './uploads',\r\n    limits: { files: 2 },\r\n    onFilesLimit: function () {\r\n      // No way to add to the request that an error occurred, or respond to the client\r\n   }\r\n  });\r\n\r\n  router.post('/uploads', function(req, res) {\r\n    // Cannot tell that any of the limits has been reached so cannot inform the client\r\n  });\r\n```\r\n\r\nYou probably don't want to respond to the client directly when a limit has been hit, but you should at least be able to tell that an error occurred later on.\r\n\r\nSomething along the lines of:\r\n```\r\n  router.use('/uploads', multer({\r\n    dest: './uploads',\r\n    limits: { files: 2 },\r\n    onFilesLimit: function (file_data) {\r\n      file_data.files_limit_reached = true;\r\n   }\r\n  });\r\n\r\n  router.post('/uploads', function(req, res) {\r\n    if (file_data.files_limit_reached) {\r\n        res.json({ error: \"file limit reached\" });\r\n    }\r\n  });\r\n```\r\nSo that rather then removing the files that have hit an error or exceeded a limit they are flagged with an error message."},"comment":{"url":"https://api.github.com/repos/expressjs/multer/issues/comments/122576494","html_url":"https://github.com/expressjs/multer/issues/72#issuecomment-122576494","issue_url":"https://api.github.com/repos/expressjs/multer/issues/72","id":122576494,"user":{"login":"LinusU","id":189580,"avatar_url":"https://avatars.githubusercontent.com/u/189580?v=3","gravatar_id":"","url":"https://api.github.com/users/LinusU","html_url":"https://github.com/LinusU","followers_url":"https://api.github.com/users/LinusU/followers","following_url":"https://api.github.com/users/LinusU/following{/other_user}","gists_url":"https://api.github.com/users/LinusU/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusU/subscriptions","organizations_url":"https://api.github.com/users/LinusU/orgs","repos_url":"https://api.github.com/users/LinusU/repos","events_url":"https://api.github.com/users/LinusU/events{/privacy}","received_events_url":"https://api.github.com/users/LinusU/received_events","type":"User","site_admin":false},"created_at":"2015-07-18T18:32:15Z","updated_at":"2015-07-18T18:32:15Z","body":"Error handling is rewritten to be much more straight forward in the newly released version `1.0.0`. Please reopen if you feel that there is still room for improvements."}}