Cancel file upload on server when cancelled from client

烂漫一生 提交于 2019-12-12 04:25:32

问题


I am using kendo file upload control in my application. I select a file of 20 MB size for example. The request goes to the server which needs to upload this document to azure + insert a DB entry pointing to the blob.

Issue is, if the server has all the bytes transferred to itself and the rest of the operations takes sometime (like uploading the file and inserting an entry to DB) and at the same time, user cancels upload from client, it gets cancelled on the client end BUT server still goes ahead with the upload. How should I handle this? Any thoughts?

Thanks!


回答1:


This is not something that should be resolved using any client-side scripts as I don't believe you will be able to make new request when browser is closing and it certainly wouldn't work when connection is interrupted because of network problems or cancel. Yes there is a cancel event you should call some server side method on cancel to delete the uploaded file.

Look into this post and answer of Lukas on stackoverflow and make use of cancel event in the kendo upload.

How to stop file transfer if browser is closed/upload cancelled



来源:https://stackoverflow.com/questions/41572040/cancel-file-upload-on-server-when-cancelled-from-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!