问题
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