chore: 支持文件上传结果回调 API
parent
3aaa14cdcf
commit
4501dbb48c
|
@ -79,19 +79,31 @@ namespace LeanCloud.Storage {
|
||||||
string key = uploadToken["key"] as string;
|
string key = uploadToken["key"] as string;
|
||||||
string token = uploadToken["token"] as string;
|
string token = uploadToken["token"] as string;
|
||||||
string provider = uploadToken["provider"] as string;
|
string provider = uploadToken["provider"] as string;
|
||||||
if (provider == "s3") {
|
try {
|
||||||
// AWS
|
if (provider == "s3") {
|
||||||
LCAWSUploader uploader = new LCAWSUploader(uploadUrl, MimeType, data);
|
// AWS
|
||||||
await uploader.Upload(onProgress);
|
LCAWSUploader uploader = new LCAWSUploader(uploadUrl, MimeType, data);
|
||||||
} else if (provider == "qiniu") {
|
await uploader.Upload(onProgress);
|
||||||
// Qiniu
|
} else if (provider == "qiniu") {
|
||||||
LCQiniuUploader uploader = new LCQiniuUploader(uploadUrl, token, key, data);
|
// Qiniu
|
||||||
await uploader.Upload(onProgress);
|
LCQiniuUploader uploader = new LCQiniuUploader(uploadUrl, token, key, data);
|
||||||
} else {
|
await uploader.Upload(onProgress);
|
||||||
throw new Exception($"{provider} is not support.");
|
} else {
|
||||||
|
throw new Exception($"{provider} is not support.");
|
||||||
|
}
|
||||||
|
LCObjectData objectData = LCObjectData.Decode(uploadToken);
|
||||||
|
Merge(objectData);
|
||||||
|
_ = LCApplication.HttpClient.Post<Dictionary<string, object>>("fileCallback", data: new Dictionary<string, object> {
|
||||||
|
{ "result", true },
|
||||||
|
{ "token", token }
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
_ = LCApplication.HttpClient.Post<Dictionary<string, object>>("fileCallback", data: new Dictionary<string, object> {
|
||||||
|
{ "result", false },
|
||||||
|
{ "token", token }
|
||||||
|
});
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
LCObjectData objectData = LCObjectData.Decode(uploadToken);
|
|
||||||
Merge(objectData);
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue