{"action":"created","issue":{"url":"https://api.github.com/repos/react-component/upload/issues/17","labels_url":"https://api.github.com/repos/react-component/upload/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/react-component/upload/issues/17/comments","events_url":"https://api.github.com/repos/react-component/upload/issues/17/events","html_url":"https://github.com/react-component/upload/issues/17","id":107872747,"number":17,"title":"选择文件后如何阻止文件上传","user":{"login":"stonelee","id":571863,"avatar_url":"https://avatars.githubusercontent.com/u/571863?v=3","gravatar_id":"","url":"https://api.github.com/users/stonelee","html_url":"https://github.com/stonelee","followers_url":"https://api.github.com/users/stonelee/followers","following_url":"https://api.github.com/users/stonelee/following{/other_user}","gists_url":"https://api.github.com/users/stonelee/gists{/gist_id}","starred_url":"https://api.github.com/users/stonelee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stonelee/subscriptions","organizations_url":"https://api.github.com/users/stonelee/orgs","repos_url":"https://api.github.com/users/stonelee/repos","events_url":"https://api.github.com/users/stonelee/events{/privacy}","received_events_url":"https://api.github.com/users/stonelee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-23T08:34:55Z","updated_at":"2015-09-23T12:42:59Z","closed_at":null,"body":"在上传之前，有时候需要对已选择的文件进行校验，例如大小、类型等等。\r\n目前可以在onStart中进行校验，但是校验失败时，无法阻止上传请求的发送。\r\n"},"comment":{"url":"https://api.github.com/repos/react-component/upload/issues/comments/142586559","html_url":"https://github.com/react-component/upload/issues/17#issuecomment-142586559","issue_url":"https://api.github.com/repos/react-component/upload/issues/17","id":142586559,"user":{"login":"stonelee","id":571863,"avatar_url":"https://avatars.githubusercontent.com/u/571863?v=3","gravatar_id":"","url":"https://api.github.com/users/stonelee","html_url":"https://github.com/stonelee","followers_url":"https://api.github.com/users/stonelee/followers","following_url":"https://api.github.com/users/stonelee/following{/other_user}","gists_url":"https://api.github.com/users/stonelee/gists{/gist_id}","starred_url":"https://api.github.com/users/stonelee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stonelee/subscriptions","organizations_url":"https://api.github.com/users/stonelee/orgs","repos_url":"https://api.github.com/users/stonelee/repos","events_url":"https://api.github.com/users/stonelee/events{/privacy}","received_events_url":"https://api.github.com/users/stonelee/received_events","type":"User","site_admin":false},"created_at":"2015-09-23T12:42:59Z","updated_at":"2015-09-23T12:42:59Z","body":"我的具体业务场景还没那么简单呢，校验是异步的，简单的return false还不行，恐怕得把request.post放出来，让业务上自己调用才好。\r\n\r\n目前我的做法是在onStart中返回一个promise，校验成功就resolve，校验失败就reject\r\n。然后在onSuccess跟onError中进行判断，成功时才回填上传文件的id。缺点就是前端校验失败也会触发上传，但是满足业务需要了~"}}