{"action":"created","issue":{"url":"https://api.github.com/repos/tomitrescak/meteor-uploads/issues/175","labels_url":"https://api.github.com/repos/tomitrescak/meteor-uploads/issues/175/labels{/name}","comments_url":"https://api.github.com/repos/tomitrescak/meteor-uploads/issues/175/comments","events_url":"https://api.github.com/repos/tomitrescak/meteor-uploads/issues/175/events","html_url":"https://github.com/tomitrescak/meteor-uploads/issues/175","id":113933552,"number":175,"title":"validateFile: fileInfo.size is always 0","user":{"login":"rteslaru","id":3188415,"avatar_url":"https://avatars.githubusercontent.com/u/3188415?v=3","gravatar_id":"","url":"https://api.github.com/users/rteslaru","html_url":"https://github.com/rteslaru","followers_url":"https://api.github.com/users/rteslaru/followers","following_url":"https://api.github.com/users/rteslaru/following{/other_user}","gists_url":"https://api.github.com/users/rteslaru/gists{/gist_id}","starred_url":"https://api.github.com/users/rteslaru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rteslaru/subscriptions","organizations_url":"https://api.github.com/users/rteslaru/orgs","repos_url":"https://api.github.com/users/rteslaru/repos","events_url":"https://api.github.com/users/rteslaru/events{/privacy}","received_events_url":"https://api.github.com/users/rteslaru/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-28T21:56:05Z","updated_at":"2015-11-18T00:16:47Z","closed_at":null,"body":"Hi,\r\n\r\nThanks for a great package, this is proving to be really useful! I just ran into a bit of an issue, however.\r\n\r\nI'm trying to use the `validateFile: function(fileInfo)` and `return true` if `fileInfo.size < maxSize` -- however, size is always set to 0.\r\n\r\nThis is the object that gets passed to the callback:\r\n\r\n```javascript\r\n{ \r\ndomain: null,\r\n_events: {},\r\n_maxListeners: 10,\r\nsize: 0,\r\npath: '/tmp/.uploads/8b7cdf076c7c218a464f813e0b7abf85',\r\nname: 'filename.JPG',\r\ntype: 'image/jpeg',\r\nhash: null,\r\nlastModifiedDate: null,\r\n_writeStream: null \r\n}\r\n```\r\n\r\nDo you have any suggestion on where to start looking for a fix?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/tomitrescak/meteor-uploads/issues/comments/157552510","html_url":"https://github.com/tomitrescak/meteor-uploads/issues/175#issuecomment-157552510","issue_url":"https://api.github.com/repos/tomitrescak/meteor-uploads/issues/175","id":157552510,"user":{"login":"tomitrescak","id":2682705,"avatar_url":"https://avatars.githubusercontent.com/u/2682705?v=3","gravatar_id":"","url":"https://api.github.com/users/tomitrescak","html_url":"https://github.com/tomitrescak","followers_url":"https://api.github.com/users/tomitrescak/followers","following_url":"https://api.github.com/users/tomitrescak/following{/other_user}","gists_url":"https://api.github.com/users/tomitrescak/gists{/gist_id}","starred_url":"https://api.github.com/users/tomitrescak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomitrescak/subscriptions","organizations_url":"https://api.github.com/users/tomitrescak/orgs","repos_url":"https://api.github.com/users/tomitrescak/repos","events_url":"https://api.github.com/users/tomitrescak/events{/privacy}","received_events_url":"https://api.github.com/users/tomitrescak/received_events","type":"User","site_admin":false},"created_at":"2015-11-18T00:16:46Z","updated_at":"2015-11-18T00:16:46Z","body":"@rteslaru, sorry for a very late response. There was an error in the package which is now fixed. I have also updated the documentation that states that failed validation returns a *description of validation error* and passed validation returns null. Asa failsafe, I have added the possibility to return null with the default text of \"validationFailed\".\r\n\r\nConcerning the file size. You were right! I amd calling validation BEFORE the file has uploaded to the server, thus server did not know about the file size. As a result I have moved the validation to state when file is uploaded to the server.\r\n\r\nThis way, you can use Validate request to cancel any upload that is not valid BEFORE it starts uploading. And you can use validateFile to validate the integrity of uploaded file AFTER it was uploaded on the server."}}