fix:上传前检测+上传次数限制

This commit is contained in:
lan
2022-12-27 13:27:23 +08:00
parent 96a926875f
commit b83497c4c8
3 changed files with 11 additions and 35 deletions
+1 -4
View File
@@ -16,11 +16,8 @@ async def admin_required(pwd: Union[str, None] = Header(default=None), request:
class IPRateLimit:
ips = {}
count = 0
minutes = 0
def __init__(self, count, minutes):
self.ips = {}
self.count = count
self.minutes = minutes
-24
View File
@@ -9,30 +9,6 @@ from fastapi import UploadFile
import settings
class TencentCOS:
def __init__(self, bucket: str, region: str, secret_id: str, secret_key: str):
self.bucket = bucket
self.region = region
self.secret_id = secret_id
self.secret_key = secret_key
def upload(self, file: UploadFile, path: str) -> str:
# 上传文件
pass
def download(self, path: str) -> BinaryIO:
# 下载文件
pass
def delete(self, path: str) -> None:
# 删除文件
pass
def get_url(self, path: str) -> str:
# 获取文件访问链接
pass
class FileSystemStorage:
DATA_ROOT = Path(settings.DATA_ROOT)
STATIC_URL = settings.STATIC_URL
+10 -7
View File
@@ -397,20 +397,23 @@
this.code = value;
},
checkFile: function (file) {
if (!this.enable) {
if (!this.enableUpload) {
this.$message({
message: '上传功能已关闭',
type: 'error'
});
return false
}
if (file.size > this.fileSizeLimit) {
this.$message({
message: `文件大小不能超过${this.fileSizeLimit/1024/1024}MB`,
type: 'error'
});
return false
if (file != null) {
if (file.size > this.fileSizeLimit) {
this.$message({
message: `文件大小不能超过${this.fileSizeLimit/1024/1024}MB`,
type: 'error'
});
return false;
}
}
return true;
},
toUploadData: function () {
if (this.uploadData.text === '' && this.uploadData.file === null) {