{"action":"created","issue":{"url":"https://api.github.com/repos/sffc/socketio-file-upload/issues/69","repository_url":"https://api.github.com/repos/sffc/socketio-file-upload","labels_url":"https://api.github.com/repos/sffc/socketio-file-upload/issues/69/labels{/name}","comments_url":"https://api.github.com/repos/sffc/socketio-file-upload/issues/69/comments","events_url":"https://api.github.com/repos/sffc/socketio-file-upload/issues/69/events","html_url":"https://github.com/sffc/socketio-file-upload/issues/69","id":279577210,"node_id":"MDU6SXNzdWUyNzk1NzcyMTA=","number":69,"title":"Ability to cancel an upload in progress","user":{"login":"TroyWolf","id":6349163,"node_id":"MDQ6VXNlcjYzNDkxNjM=","avatar_url":"https://avatars1.githubusercontent.com/u/6349163?v=4","gravatar_id":"","url":"https://api.github.com/users/TroyWolf","html_url":"https://github.com/TroyWolf","followers_url":"https://api.github.com/users/TroyWolf/followers","following_url":"https://api.github.com/users/TroyWolf/following{/other_user}","gists_url":"https://api.github.com/users/TroyWolf/gists{/gist_id}","starred_url":"https://api.github.com/users/TroyWolf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TroyWolf/subscriptions","organizations_url":"https://api.github.com/users/TroyWolf/orgs","repos_url":"https://api.github.com/users/TroyWolf/repos","events_url":"https://api.github.com/users/TroyWolf/events{/privacy}","received_events_url":"https://api.github.com/users/TroyWolf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-06T00:09:43Z","updated_at":"2018-06-14T08:56:10Z","closed_at":null,"author_association":"NONE","body":"How difficult would it be to provide a method to cancel an in-progress file upload? Dropzone.js offers this functionality: http://www.dropzonejs.com/#config-addRemoveLinks. I'm thinking something similar.\r\n\r\nTo understand why someone might want this, \"accidentally\" drop a folder with a dozen 500MB video files onto your application's dropzone. It would be nice if the user could click to cancel either individual files or all files.\r\n"},"comment":{"url":"https://api.github.com/repos/sffc/socketio-file-upload/issues/comments/397222677","html_url":"https://github.com/sffc/socketio-file-upload/issues/69#issuecomment-397222677","issue_url":"https://api.github.com/repos/sffc/socketio-file-upload/issues/69","id":397222677,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NzIyMjY3Nw==","user":{"login":"ryanaltair","id":2869522,"node_id":"MDQ6VXNlcjI4Njk1MjI=","avatar_url":"https://avatars3.githubusercontent.com/u/2869522?v=4","gravatar_id":"","url":"https://api.github.com/users/ryanaltair","html_url":"https://github.com/ryanaltair","followers_url":"https://api.github.com/users/ryanaltair/followers","following_url":"https://api.github.com/users/ryanaltair/following{/other_user}","gists_url":"https://api.github.com/users/ryanaltair/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanaltair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanaltair/subscriptions","organizations_url":"https://api.github.com/users/ryanaltair/orgs","repos_url":"https://api.github.com/users/ryanaltair/repos","events_url":"https://api.github.com/users/ryanaltair/events{/privacy}","received_events_url":"https://api.github.com/users/ryanaltair/received_events","type":"User","site_admin":false},"created_at":"2018-06-14T08:56:10Z","updated_at":"2018-06-14T08:56:10Z","author_association":"NONE","body":"exactly, siofu have this feature already\r\n\r\nat doc, we can cancel(abort) the upload with\r\n`instance.abort(id, socket)`\r\n\r\nSadly, tha'st a bit hard to used (if wrong, correct me please) when cancel a specific upload\r\n\r\n\r\non web side \r\n```\r\nlet serialNum = 0\r\nfunction startAddMeta (event) {\r\n// we make every upload a own tag before we upload\r\n  event.file.meta.serialNum = serialNum // tag it\r\n  siofu.removeEventListener('start', startAddMeta)\r\n}\r\nsiofu.addEventListener('start', startAddMeta)\r\n\r\nfunction cancelUpload() { // use this to cancel \r\n  console.log('cancel serial num ', 2)// now we will cancel the No.2 upload\r\n  socket.emit('abortupload', 2)\r\n})\r\n\r\n``` \r\n\r\non server side\r\n```\r\nlet needaborts = []\r\nsocket.on('abortupload', function (whichAbort) {\r\n  needaborts.push(Number(whichAbort))\r\n})\r\n\r\nuploader.on('progress', function (event) {\r\n// check if cancel needed when process event happen\r\n  while (needaborts.length > 0) {\r\n    let slotaborted = needaborts.pop()\r\n    if (Number(event.file.meta.serialNum) === slotaborted) {\r\n      uploader.abort(event.file.id, socket)\r\n    }\r\n  }\r\n})\r\n\r\n```\r\n"}}
{"actor":{"display_login":"ryanaltair"}}