@newview/file-ui 1.1.39 → 1.1.41
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/dist/file-ui.js +59 -59
- package/dist/file-ui.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/file-ui.js
CHANGED
|
@@ -371,6 +371,65 @@ let UploadFileInstance$1 = class UploadFileInstance extends BaseInstance {
|
|
|
371
371
|
}
|
|
372
372
|
});
|
|
373
373
|
});
|
|
374
|
+
/**
|
|
375
|
+
* 文件分片上传
|
|
376
|
+
* @param file
|
|
377
|
+
*/
|
|
378
|
+
__publicField(this, "multipartUpload", async (file) => {
|
|
379
|
+
let _this = this;
|
|
380
|
+
let fileName = file.name;
|
|
381
|
+
let temp1 = fileName.split(".");
|
|
382
|
+
let ext = temp1[temp1.length - 1];
|
|
383
|
+
let ossContentType = this.getOssContentType(fileName);
|
|
384
|
+
let fileMark = this.utilities.getCurrentDate("YYYYMMDDHHmmss") + "_" + file.name;
|
|
385
|
+
let ossClient = await new OSSFileApi().getOSSClient();
|
|
386
|
+
const userInfo = this.storageInfo.getUser();
|
|
387
|
+
const business = this.storageInfo.getCurrentBusiness();
|
|
388
|
+
const module = this.storageInfo.getCurrentModule();
|
|
389
|
+
const platform = this.storageInfo.getCurrentPlatform();
|
|
390
|
+
let businessName = business ? business == null ? void 0 : business.ModuleAlias : "非业务";
|
|
391
|
+
let moduleName = module ? module == null ? void 0 : module.ModuleAlias : "非业务";
|
|
392
|
+
let moduleName2 = businessName + "/" + moduleName;
|
|
393
|
+
let FileCabinePath = (platform == null ? void 0 : platform.OssRootPath) + "/" + moduleName2 + "/";
|
|
394
|
+
let newFileName = `${FileCabinePath}${this.props.catalog}/${this.currentToken}/${fileMark}`;
|
|
395
|
+
const result = await ossClient.multipartUpload(newFileName, file, {
|
|
396
|
+
async progress(p) {
|
|
397
|
+
_this.uploadingPercent.value = (p * 100).toFixed(0);
|
|
398
|
+
},
|
|
399
|
+
mime: ossContentType
|
|
400
|
+
});
|
|
401
|
+
if (result.res.statusCode === 200) {
|
|
402
|
+
let fileInfo = {
|
|
403
|
+
"FileCabinetId": (module == null ? void 0 : module.Id) ? module == null ? void 0 : module.Id : 0,
|
|
404
|
+
"FileCabinePath": FileCabinePath,
|
|
405
|
+
"Catalog": this.props.catalog,
|
|
406
|
+
"Token": this.currentToken,
|
|
407
|
+
"GroupName": this.activeGroupName.value,
|
|
408
|
+
"FileMark": fileMark,
|
|
409
|
+
"FileName": fileName,
|
|
410
|
+
"FileExt": ext,
|
|
411
|
+
"FileSize": file.size,
|
|
412
|
+
"ExtraInfo": this.props.extraInfo,
|
|
413
|
+
"CreateUserId": userInfo == null ? void 0 : userInfo.Id,
|
|
414
|
+
"CreateUserName": userInfo == null ? void 0 : userInfo.UserName,
|
|
415
|
+
"CreateTime": this.utilities.getCurrentDate(),
|
|
416
|
+
"Id": 0
|
|
417
|
+
};
|
|
418
|
+
let infoSaveRes = this.utilities.parseApiResult(await this.fileInfoApi.save(fileInfo));
|
|
419
|
+
if (infoSaveRes) {
|
|
420
|
+
this.message.success("上传成功!");
|
|
421
|
+
this.ctx.emit("success", { token: this.currentToken, fileId: infoSaveRes });
|
|
422
|
+
this.loadFileList(true);
|
|
423
|
+
this.uploadingPercent.value = 100;
|
|
424
|
+
} else {
|
|
425
|
+
this.message.error("网络出现异常,再次上传");
|
|
426
|
+
this.uploadingPercent.value = 0;
|
|
427
|
+
}
|
|
428
|
+
} else {
|
|
429
|
+
this.message.error("网络出现异常,再次上传");
|
|
430
|
+
this.uploadingPercent.value = 0;
|
|
431
|
+
}
|
|
432
|
+
});
|
|
374
433
|
/**
|
|
375
434
|
* 移除
|
|
376
435
|
* @param fileInfo
|
|
@@ -620,65 +679,6 @@ let UploadFileInstance$1 = class UploadFileInstance extends BaseInstance {
|
|
|
620
679
|
}
|
|
621
680
|
this.setPreviewList();
|
|
622
681
|
}
|
|
623
|
-
/**
|
|
624
|
-
* 文件分片上传
|
|
625
|
-
* @param file
|
|
626
|
-
*/
|
|
627
|
-
async multipartUpload(file) {
|
|
628
|
-
let _this = this;
|
|
629
|
-
let fileName = file.name;
|
|
630
|
-
let temp1 = fileName.split(".");
|
|
631
|
-
let ext = temp1[temp1.length - 1];
|
|
632
|
-
let ossContentType = this.getOssContentType(fileName);
|
|
633
|
-
let fileMark = this.utilities.getCurrentDate("YYYYMMDDHHmmss") + "." + ext;
|
|
634
|
-
let ossClient = await new OSSFileApi().getOSSClient();
|
|
635
|
-
const userInfo = this.storageInfo.getUser();
|
|
636
|
-
const business = this.storageInfo.getCurrentBusiness();
|
|
637
|
-
const module = this.storageInfo.getCurrentModule();
|
|
638
|
-
const platform = this.storageInfo.getCurrentPlatform();
|
|
639
|
-
let businessName = business ? business == null ? void 0 : business.ModuleAlias : "非业务";
|
|
640
|
-
let moduleName = module ? module == null ? void 0 : module.ModuleAlias : "非业务";
|
|
641
|
-
let moduleName2 = businessName + "/" + moduleName;
|
|
642
|
-
let FileCabinePath = (platform == null ? void 0 : platform.OssRootPath) + "/" + moduleName2 + "/";
|
|
643
|
-
let newFileName = `${FileCabinePath}${this.props.catalog}/${this.currentToken}/${fileMark}`;
|
|
644
|
-
const result = await ossClient.multipartUpload(newFileName, file, {
|
|
645
|
-
async progress(p) {
|
|
646
|
-
_this.uploadingPercent.value = (p * 100).toFixed(0);
|
|
647
|
-
},
|
|
648
|
-
mime: ossContentType
|
|
649
|
-
});
|
|
650
|
-
if (result.res.statusCode === 200) {
|
|
651
|
-
let fileInfo = {
|
|
652
|
-
"FileCabinetId": (module == null ? void 0 : module.Id) ? module == null ? void 0 : module.Id : 0,
|
|
653
|
-
"FileCabinePath": FileCabinePath,
|
|
654
|
-
"Catalog": this.props.catalog,
|
|
655
|
-
"Token": this.currentToken,
|
|
656
|
-
"GroupName": this.activeGroupName.value,
|
|
657
|
-
"FileMark": fileMark,
|
|
658
|
-
"FileName": fileName,
|
|
659
|
-
"FileExt": ext,
|
|
660
|
-
"FileSize": file.size,
|
|
661
|
-
"ExtraInfo": this.props.extraInfo,
|
|
662
|
-
"CreateUserId": userInfo == null ? void 0 : userInfo.Id,
|
|
663
|
-
"CreateUserName": userInfo == null ? void 0 : userInfo.UserName,
|
|
664
|
-
"CreateTime": this.utilities.getCurrentDate(),
|
|
665
|
-
"Id": 0
|
|
666
|
-
};
|
|
667
|
-
let infoSaveRes = this.utilities.parseApiResult(await this.fileInfoApi.save(fileInfo));
|
|
668
|
-
if (infoSaveRes) {
|
|
669
|
-
this.message.success("上传成功!");
|
|
670
|
-
this.ctx.emit("success", { token: this.currentToken, fileId: infoSaveRes });
|
|
671
|
-
this.loadFileList(true);
|
|
672
|
-
this.uploadingPercent.value = 100;
|
|
673
|
-
} else {
|
|
674
|
-
this.message.error("网络出现异常,再次上传");
|
|
675
|
-
this.uploadingPercent.value = 0;
|
|
676
|
-
}
|
|
677
|
-
} else {
|
|
678
|
-
this.message.error("网络出现异常,再次上传");
|
|
679
|
-
this.uploadingPercent.value = 0;
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
682
|
getOssContentType(fileName) {
|
|
683
683
|
if (fileName.indexOf(".bmp") > -1) {
|
|
684
684
|
return "image/bmp";
|