diff --git a/Storage/Storage/LCFile.cs b/Storage/Storage/LCFile.cs index 19e1964..8e504f9 100644 --- a/Storage/Storage/LCFile.cs +++ b/Storage/Storage/LCFile.cs @@ -79,19 +79,31 @@ namespace LeanCloud.Storage { string key = uploadToken["key"] as string; string token = uploadToken["token"] as string; string provider = uploadToken["provider"] as string; - if (provider == "s3") { - // AWS - LCAWSUploader uploader = new LCAWSUploader(uploadUrl, MimeType, data); - await uploader.Upload(onProgress); - } else if (provider == "qiniu") { - // Qiniu - LCQiniuUploader uploader = new LCQiniuUploader(uploadUrl, token, key, data); - await uploader.Upload(onProgress); - } else { - throw new Exception($"{provider} is not support."); + try { + if (provider == "s3") { + // AWS + LCAWSUploader uploader = new LCAWSUploader(uploadUrl, MimeType, data); + await uploader.Upload(onProgress); + } else if (provider == "qiniu") { + // Qiniu + LCQiniuUploader uploader = new LCQiniuUploader(uploadUrl, token, key, data); + await uploader.Upload(onProgress); + } else { + throw new Exception($"{provider} is not support."); + } + LCObjectData objectData = LCObjectData.Decode(uploadToken); + Merge(objectData); + _ = LCApplication.HttpClient.Post>("fileCallback", data: new Dictionary { + { "result", true }, + { "token", token } + }); + } catch (Exception e) { + _ = LCApplication.HttpClient.Post>("fileCallback", data: new Dictionary { + { "result", false }, + { "token", token } + }); + throw e; } - LCObjectData objectData = LCObjectData.Decode(uploadToken); - Merge(objectData); } return this; }