Cancel file upload when session is terminated

This commit is contained in:
2024-09-15 17:41:33 +07:00
parent eee047a9b0
commit 4ee86d0fc4
2 changed files with 9 additions and 1 deletions

View File

@ -93,5 +93,6 @@ func POST(w http.ResponseWriter, r *http.Request) {
return return
} }
w.WriteHeader(http.StatusAccepted)
return return
} }

View File

@ -163,10 +163,17 @@ async function uploadChunks(name, size, chunks, chunkArray, FileID) {
const startTime = performance.now(); const startTime = performance.now();
try { try {
await fetch(`/file/${FileID}`, { const request = await fetch(`/file/${FileID}`, {
method: 'POST', method: 'POST',
body: formData body: formData
}); });
console.log(request.status)
if (request.status !== 202) {
ChangeModal("Error", "There was an issue with your upload. Please try again later or contact support if the problem persists.")
toggleModal();
isFailed = true
break
}
} catch (error) { } catch (error) {
ChangeModal("Error", "There was an issue with your upload. Please try again later or contact support if the problem persists.") ChangeModal("Error", "There was an issue with your upload. Please try again later or contact support if the problem persists.")
toggleModal(); toggleModal();