Skip to content

Commit 48d2bfc

Browse files
committed
Invoke fileCallback after file uploaded (or failed so)
1 parent 557d30a commit 48d2bfc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/LeanCloud/File.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,23 @@ public function save() {
380380
$resp["token"] = null;
381381
}
382382

383+
$callbackParams = array("token" => $resp["token"]);
383384
try {
384385
$uploader = SimpleUploader::createUploader($resp["provider"]);
385386
$uploader->initialize($resp["upload_url"], $resp["token"]);
386387
$uploader->upload($this->_source, $this->getMimeType(), $key);
388+
$callbackParams["result"] = false;
387389
} catch (\Exception $ex) {
388-
$this->destroy();
390+
$callbackParams["result"] = false;
389391
throw $ex;
392+
} finally {
393+
try {
394+
Client::post("/fileCallback", $callbackParams);
395+
} catch (\Exception $ex) {
396+
error_log("Request /fileCallback failed.");
397+
}
390398
}
399+
391400
forEach(array("upload_url", "token") as $k) {
392401
if (isset($resp[$k])) {
393402
unset($resp[$k]);

0 commit comments

Comments
 (0)