django-vue3-admin-web/node_modules/@fast-crud/fast-extends/dist/uploader-alioss-4003d93a.mjs
2025-10-20 21:21:14 +08:00

52 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { merge as y, cloneDeep as d } from "lodash-es";
import { b as g, u as m } from "./index-50ffe046.mjs";
import l from "ali-oss";
import "vue";
import "@fast-crud/fast-crud";
let a = null;
async function f(e) {
if (a != null && a.expiresTime > (/* @__PURE__ */ new Date()).getTime())
return a;
const n = await e.getAuthorization(e);
return a = n, a.expiresTime == null && (a.expiresTime = (/* @__PURE__ */ new Date()).getTime() + parseInt(n.expiration)), a;
}
async function p(e, s, n) {
let c = null;
!e.accessKeyId && !e.accessKeySecret && e.getAuthorization !== null ? c = await f({
key: s,
file: n,
...e
}) : console.warn("您还未配置getAuthorization将使用accessKeySecret作为授权进行上传");
let t = null;
return c != null ? (t = new l({
region: e.region,
accessKeyId: c.accessKeyId,
accessKeySecret: c.accessKeySecret,
stsToken: c.securityToken,
bucket: e.bucket,
...e.sdkOpts
}), s = c.key || s) : t = new l({
region: e.region,
accessKeyId: e.accessKeyId,
accessKeySecret: e.accessKeySecret,
bucket: e.bucket,
...e.sdkOpts
}), { client: t, key: s };
}
async function w(e) {
const { file: s, fileName: n, onProgress: c } = e, t = e.options, o = await g(s, n, t), { client: u, key: i } = await p(t, o, s);
await u.put(i, s);
let r = { url: t.domain + "/" + i, key: i };
return t.successHandle && (r = await t.successHandle(r, t)), r;
}
async function I(e) {
const { getConfig: s } = m(), n = s("alioss"), c = e.options, t = y(d(n), c);
return e.options = t, await w(e);
}
export {
p as getOssClient,
f as getSts,
I as upload
};
//# sourceMappingURL=uploader-alioss-4003d93a.mjs.map