上传文件 小于10KB可以上传,超过就提示跨域问题

今天维护一个微服务项目,基于若依cloud版本;系统运行了一年多了,突然反馈注册上传附件图片失败;F12定位查看提示跨域COSR ;程序之前都是正常,怎么突然跨域了?

开始解决跨域问题,各种尝试,重启服务。还是没有解决!!!!!!!!

一个同事提示,说是Nginx配置上传文件大小问题;掉转方向进行Nginx配置;一通操作,还是不行!!!!!!

查看Nginx日志,发现说磁盘不足了。。。。

然后看了下Nginx的access.log

20.01GB 滴个乖乖!果断停掉Nginx服务,把日志拷贝到其他地方;重新启动Nginx服务;

之前原有的上传操作,呕吼!!!!竟然可以了。。。。。。。。。。。

记录一下,因为日志存储空间问题不止一次,Nacos也遇到过,MySQL也遇到过。。。。。

<template> <div class="upload-view"> <el-upload ref="uploadRef" class="upload-v" drag action="#" :show-file-list="false" :accept="fileAccept" :autoUpload="false" :onChange="fileUpload"> <!-- 开始上传 --> <div v-if="!fileList.length"> <SvgIcon icon="public-upload" :size="36" /> <div class="upload__text">将文件拖拽至此区,或 <span class="text">点击上传</span></div> </div> <template v-if="fileList.length"> <div class="file-item" v-for="file in fileList" :key="file.id"> <div class="file-info"> <SvgIcon :icon="file.icon" :size="52" /> <div> <div class="file-name">{{ file?.fieldName }}</div> <div class="file-size">{{ `(${(Number(file?.fieldSize) / 1024).toFixed(2)}KB)` }}</div> </div> </div> <div class="file-progress" v-if="file?.progress !== 100 && !fileReturnData?.some((i: any) => i.errorFileName)"> <el-progress :percentage="file?.progress" /> <div class="close" @click.stop="removeFile(file.id)"> <SvgIcon icon="public-close" :size="16" /> </div> </div> <el-button v-if="file?.progress === 100 && !fileReturnData?.some((i: any) => i.errorFileName)" @click.stop="removeFile(file.id)">重新选择</el-button> <!-- 插槽 --> <slot :file="file" /> </div> </template> </el-upload> </div> </template> <script setup lang="ts"> import { ref, reactive } from "vue"; import { ElMessage, type UploadFile } from "element-plus"; // import { aliyunUpload } from "@utils/uploadLib"; import { generateUUID } from "@/utils/lib"; import type { FileObject } from "./index.d"; defineOptions({ name: "UploadFile" }); // 已上传文件列表 const fileList = ref<FileObject[]>([]); const fileReturnData = ref([]); const props = withDefaults( defineProps<{ fileAccept?: string; limit?: number; // 导出的api uploadApi: Function; }>(), { limit: 1, fileAccept: ".zip,.rar,.txt,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.jpg,.jpeg,.png,.avi,.mp4" } ); const emit = defineEmits(["change"]); /** * @description: 删除文件 * @param {*} id * @return {*} */ const removeFile = (id: string) => { fileList.value = fileList.value.filter((item) => item.id !== id); }; /** * @description: 文件上传 * @param {*} file * @return {*} */ const fileUpload = async (file: UploadFile) => { console.log("🚀 ~ fileUpload ~ file:", file) if (props.limit && fileList.value.length === props.limit) { ElMessage.warning(`最多上传${props.limit}个文件`); return; } let fileSuffix = (file.name || "").substring((file.name || "").lastIndexOf(".") + 1, file.name?.length); const fileObject = reactive({ id: generateUUID(), fieldName: file.name, fieldSize: file.size, icon: `manage-d_${fileSuffix}`, progress: 0, fieldValue: "" }); fileList.value.unshift(fileObject); try { // let { url } = await aliyunUpload(file.raw!, {}, 1); // fileObject.fieldValue = url; const formData = new FormData(); formData.append("uploadFile", file.raw!); let { data } = await props.uploadApi(formData); fileReturnData.value = data; fileObject.progress = 100; emit("change", data, fileList.value); } catch (error) { console.log(error); } }; defineExpose({ removeFile }); </script> <style lang="scss" scoped> .upload-view { height: 100%; .upload-v { height: 300px; :deep(.el-upload) { height: 100%; .el-upload-dragger { height: 100%; display: flex; align-items: center; justify-content: center; } } .upload__text { margin-top: 20px; font-weight: 500; font-size: 16px; color: #333333; .text { color: var(--color-primary); } } .file-item { .file-info { display: flex; flex-direction: column; justify-content: space-between; align-items: center; margin-bottom: 6px; .svg-icon { margin-bottom: 16px; } .file-name { font-weight: 500; font-size: 16px; color: #333333; } .file-size { margin-top: 4px; font-weight: 400; font-size: 14px; color: #999999; } // .svg-icon { // color: var(--color-primary); // } } .file-progress { margin-top: 30px; display: flex; align-items: center; :deep(.el-progress) { flex: 1; .el-progress-bar { width: 400px; } .el-progress__text { font-weight: 400; font-size: 14px !important; color: #999999; } } .close { cursor: pointer; color: #fff; } } .el-button { margin-top: 30px; height: 40px; padding: 6px 26px; } } } } </style>
最新发布
12-09
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值