This commit is contained in:
张良(004796)
2024-02-23 15:20:18 +08:00
parent 043823c19f
commit 830e6ef3f5

View File

@@ -20,6 +20,8 @@ type Policy = {
keySecret: string, keySecret: string,
region: string, region: string,
token: string, token: string,
cdnDomain: string
} }
/** /**
@@ -41,7 +43,8 @@ export function useUpload() {
keyId: "", keyId: "",
keySecret: "", keySecret: "",
region: "", region: "",
token: "" token: "",
cdnDomain: ""
}; };
const init = () => { const init = () => {
@@ -149,7 +152,11 @@ export function useUpload() {
headers: { "Content-Type": "text/plain" }, headers: { "Content-Type": "text/plain" },
}; };
const result = await client.put(getRandomFileName(), file, options); const result = await client.put(getRandomFileName(), file, options);
callback && callback(result?.url); let ppUrl = result?.url
if(policy.cdnDomain){
ppUrl = policy.cdnDomain + result.name
}
callback && callback(ppUrl);
return Promise.resolve() return Promise.resolve()
} catch (e) { } catch (e) {
console.log(e); console.log(e);