mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-22 08:13:49 +00:00
several fixes in actual temporal upload of js client
This commit is contained in:
parent
21195e1bcb
commit
9c667f4b78
@ -28,22 +28,26 @@ suspend fun tempUpload(
|
||||
if (request.status == 200.toShort()) {
|
||||
answer.complete(TemporalFileId(request.responseText))
|
||||
} else {
|
||||
answer.completeExceptionally(Exception("Something went wrong"))
|
||||
answer.completeExceptionally(Exception("Something went wrong: $it"))
|
||||
}
|
||||
}
|
||||
request.onerror = {
|
||||
answer.completeExceptionally(Exception("Something went wrong"))
|
||||
answer.completeExceptionally(Exception("Something went wrong: $it"))
|
||||
}
|
||||
request.open("POST", fullTempUploadDraftPath, true)
|
||||
request.send(formData)
|
||||
|
||||
currentCoroutineContext().job.invokeOnCompletion {
|
||||
val handle = currentCoroutineContext().job.invokeOnCompletion {
|
||||
runCatching {
|
||||
request.abort()
|
||||
}
|
||||
}
|
||||
|
||||
return answer.await()
|
||||
return runCatching {
|
||||
answer.await()
|
||||
}.also {
|
||||
handle.dispose()
|
||||
}.getOrThrow()
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user