{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/skipper/issues/89","labels_url":"https://api.github.com/repos/balderdashy/skipper/issues/89/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/skipper/issues/89/comments","events_url":"https://api.github.com/repos/balderdashy/skipper/issues/89/events","html_url":"https://github.com/balderdashy/skipper/issues/89","id":84114367,"number":89,"title":"How to detect missing or empty file field and abort, avoiding Upstream timout exception?","user":{"login":"plato-cambrian","id":7917920,"avatar_url":"https://avatars.githubusercontent.com/u/7917920?v=3","gravatar_id":"","url":"https://api.github.com/users/plato-cambrian","html_url":"https://github.com/plato-cambrian","followers_url":"https://api.github.com/users/plato-cambrian/followers","following_url":"https://api.github.com/users/plato-cambrian/following{/other_user}","gists_url":"https://api.github.com/users/plato-cambrian/gists{/gist_id}","starred_url":"https://api.github.com/users/plato-cambrian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plato-cambrian/subscriptions","organizations_url":"https://api.github.com/users/plato-cambrian/orgs","repos_url":"https://api.github.com/users/plato-cambrian/repos","events_url":"https://api.github.com/users/plato-cambrian/events{/privacy}","received_events_url":"https://api.github.com/users/plato-cambrian/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-02T17:17:35Z","updated_at":"2015-09-22T05:43:07Z","closed_at":null,"body":"When I receive a post to `/api/files.upload`, I need to \r\n1) verify there is a file that was posted under the name `file` or send 400 response\r\n2) proceed to detect MIME type from magic bytes, send 400 response if non-image\r\n3) upload to s3 with skipper-s3\r\n\r\nIt's unclear to me how to handle step 1. I've pasted my attempt below. The 1 second timeout helps avoid a race condition where Skipper tries to process the request before it receives the body. If a post is received without the file, Skipper crashes the server shortly after I `return callback('no file buffer available');`.\r\n```\r\n  sopro.files.handleUploadWrapper = function(opts, callback){\r\n    var req = opts.req;\r\n    if (req.file('file')._readableState.buffer.length === 0) {\r\n      setTimeout(function(){\r\n        if (req.file('file')._readableState.buffer.length === 0) {\r\n          return callback('no file buffer available');\r\n        }\r\n        sopro.files.handleUpload(opts, callback); // read magic bytes then call req.file('file').upload()\r\n      }, 1000)\r\n    } else {\r\n      sopro.files.handleUpload(opts, callback);\r\n    }\r\n  }\r\n```\r\n\r\n```\r\nError: EMAXBUFFER: An Upstream (`NOOP_file`) timed out before it was plugged into a receiver. It was still unused after waiting 4500ms. You can configure this timeout by changing the `maxTimeToBuffer` option.\r\n    at null.<anonymous> (C:\\dev\\src\\sopro\\apps\\chat\\node_modules\\skipper\\standalone\\Upstream\\Upstream.js:86:15)\r\n    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)\r\n```"},"comment":{"url":"https://api.github.com/repos/balderdashy/skipper/issues/comments/142186018","html_url":"https://github.com/balderdashy/skipper/issues/89#issuecomment-142186018","issue_url":"https://api.github.com/repos/balderdashy/skipper/issues/89","id":142186018,"user":{"login":"sailsbot","id":14700466,"avatar_url":"https://avatars.githubusercontent.com/u/14700466?v=3","gravatar_id":"","url":"https://api.github.com/users/sailsbot","html_url":"https://github.com/sailsbot","followers_url":"https://api.github.com/users/sailsbot/followers","following_url":"https://api.github.com/users/sailsbot/following{/other_user}","gists_url":"https://api.github.com/users/sailsbot/gists{/gist_id}","starred_url":"https://api.github.com/users/sailsbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sailsbot/subscriptions","organizations_url":"https://api.github.com/users/sailsbot/orgs","repos_url":"https://api.github.com/users/sailsbot/repos","events_url":"https://api.github.com/users/sailsbot/events{/privacy}","received_events_url":"https://api.github.com/users/sailsbot/received_events","type":"User","site_admin":false},"created_at":"2015-09-22T05:43:07Z","updated_at":"2015-09-22T05:43:07Z","body":"Thanks for posting, @plato-cambrian.  I'm a repo bot-- nice to meet you!\n\nIt has been 60 days since there have been any updates or new comments on this page.  If this issue has been resolved, feel free to disregard the rest of this message.  On the other hand, if you are still waiting on a patch, please:\n\n  + review our [contribution guide](https://github.com/balderdashy/sails/blob/master/CONTRIBUTING.md) to make sure this submission meets our criteria (only _verified bugs_ with documented features, please;  no questions, commentary, or bug reports about undocumented features or unofficial plugins)\n  + create a new issue with the latest information, including updated version details with error messages, failing tests, and a link back to [the original issue]().  This allows GitHub to automatically create a back-reference for future visitors arriving from search engines.\n\nThanks so much for your help!"}}