From 4501dbb48c27876eee16dd462e1a813ba94fd8e4 Mon Sep 17 00:00:00 2001 From: oneRain Date: Mon, 17 Aug 2020 13:19:15 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=94=AF=E6=8C=81=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BB=93=E6=9E=9C=E5=9B=9E=E8=B0=83=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Storage/Storage/LCFile.cs | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) 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; }