mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-12 19:40:06 +08:00
fix: 解决部分文件上传失败的问题 (#3343)
This commit is contained in:
parent
a9d8018e78
commit
b2926019cf
@ -94,6 +94,7 @@ import i18n from '@/lang';
|
|||||||
import DrawerHeader from '@/components/drawer-header/index.vue';
|
import DrawerHeader from '@/components/drawer-header/index.vue';
|
||||||
import { MsgError, MsgSuccess } from '@/utils/message';
|
import { MsgError, MsgSuccess } from '@/utils/message';
|
||||||
import { Close } from '@element-plus/icons-vue';
|
import { Close } from '@element-plus/icons-vue';
|
||||||
|
import { TimeoutEnum } from '@/enums/http-enum';
|
||||||
|
|
||||||
interface UploadFileProps {
|
interface UploadFileProps {
|
||||||
path: string;
|
path: string;
|
||||||
@ -235,7 +236,7 @@ const submit = async () => {
|
|||||||
const fileSize = file.size;
|
const fileSize = file.size;
|
||||||
|
|
||||||
uploadHelper.value = i18n.global.t('file.fileUploadStart', [file.name]);
|
uploadHelper.value = i18n.global.t('file.fileUploadStart', [file.name]);
|
||||||
if (fileSize <= 1024 * 1024 * 10) {
|
if (fileSize <= 1024 * 1024 * 5) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file.raw);
|
formData.append('file', file.raw);
|
||||||
if (file.raw.webkitRelativePath != '') {
|
if (file.raw.webkitRelativePath != '') {
|
||||||
@ -254,7 +255,7 @@ const submit = async () => {
|
|||||||
success++;
|
success++;
|
||||||
uploaderFiles.value[i].status = 'success';
|
uploaderFiles.value[i].status = 'success';
|
||||||
} else {
|
} else {
|
||||||
const CHUNK_SIZE = 1024 * 1024 * 10;
|
const CHUNK_SIZE = 1024 * 1024 * 5;
|
||||||
const chunkCount = Math.ceil(fileSize / CHUNK_SIZE);
|
const chunkCount = Math.ceil(fileSize / CHUNK_SIZE);
|
||||||
let uploadedChunkCount = 0;
|
let uploadedChunkCount = 0;
|
||||||
for (let c = 0; c < chunkCount; c++) {
|
for (let c = 0; c < chunkCount; c++) {
|
||||||
@ -281,7 +282,7 @@ const submit = async () => {
|
|||||||
);
|
);
|
||||||
uploadPrecent.value = progress;
|
uploadPrecent.value = progress;
|
||||||
},
|
},
|
||||||
timeout: 40000,
|
timeout: TimeoutEnum.T_60S,
|
||||||
});
|
});
|
||||||
uploadedChunkCount++;
|
uploadedChunkCount++;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user