@hzab/form-render-mobile 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -55,8 +55,18 @@ class OssUpload {
|
|
|
55
55
|
const { ossParams: propOssParams } = opt || {};
|
|
56
56
|
const formData = new FormData();
|
|
57
57
|
// key 表示上传到 Bucket 内的 Object 的完整路径,例如 exampledir/exampleobject.txtObject,完整路径中不能包含 Bucket 名称。
|
|
58
|
-
// filename表示待上传的本地文件名称。
|
|
59
|
-
|
|
58
|
+
// filename 表示待上传的本地文件名称。
|
|
59
|
+
let filename = file?.name;
|
|
60
|
+
if (file?.name) {
|
|
61
|
+
const nameArr = file?.name.match(/^(.+)\.(.+)$/);
|
|
62
|
+
if (nameArr && nameArr.length > 2) {
|
|
63
|
+
filename = `${nameArr[1]}_${Date.now()}_${Math.round(Math.random() * 1000)}.${nameArr[2]}`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (!filename) {
|
|
67
|
+
filename = `${Date.now()}.${file.type?.replace(/\w+\/, ''/)}`;
|
|
68
|
+
}
|
|
69
|
+
const key = `${ossParams?.dir}${filename}`;
|
|
60
70
|
formData.set("key", key);
|
|
61
71
|
formData.set("OSSAccessKeyId", ossParams.accessid);
|
|
62
72
|
formData.set("policy", ossParams.policy);
|