mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
fix: 解决部分文件不能上传的问题 (#2933)
This commit is contained in:
parent
fb556d6149
commit
80c68b8e49
@ -127,6 +127,7 @@ const removeFile = (index: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const fileOnChange = (_uploadFile: UploadFile, uploadFiles: UploadFiles) => {
|
const fileOnChange = (_uploadFile: UploadFile, uploadFiles: UploadFiles) => {
|
||||||
|
if (_uploadFile.size == 64 || _uploadFile.size == 0) {
|
||||||
uploaderFiles.value = uploadFiles;
|
uploaderFiles.value = uploadFiles;
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.readAsDataURL(_uploadFile.raw);
|
reader.readAsDataURL(_uploadFile.raw);
|
||||||
@ -135,6 +136,9 @@ const fileOnChange = (_uploadFile: UploadFile, uploadFiles: UploadFiles) => {
|
|||||||
uploaderFiles.value = uploaderFiles.value.filter((file) => file.uid !== _uploadFile.uid);
|
uploaderFiles.value = uploaderFiles.value.filter((file) => file.uid !== _uploadFile.uid);
|
||||||
MsgError(i18n.global.t('file.typeErrOrEmpty', [_uploadFile.name]));
|
MsgError(i18n.global.t('file.typeErrOrEmpty', [_uploadFile.name]));
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
uploaderFiles.value = uploadFiles;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearFiles = () => {
|
const clearFiles = () => {
|
||||||
@ -162,7 +166,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 * 50) {
|
if (fileSize <= 1024 * 1024 * 10) {
|
||||||
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 != '') {
|
||||||
@ -174,7 +178,7 @@ const submit = async () => {
|
|||||||
success++;
|
success++;
|
||||||
uploaderFiles.value[i].status = 'success';
|
uploaderFiles.value[i].status = 'success';
|
||||||
} else {
|
} else {
|
||||||
const CHUNK_SIZE = 1024 * 1024 * 20; // 10MB
|
const CHUNK_SIZE = 1024 * 1024 * 10;
|
||||||
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++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user