fix:上传前检测+上传次数限制
This commit is contained in:
+1
-4
@@ -16,11 +16,8 @@ async def admin_required(pwd: Union[str, None] = Header(default=None), request:
|
|||||||
|
|
||||||
|
|
||||||
class IPRateLimit:
|
class IPRateLimit:
|
||||||
ips = {}
|
|
||||||
count = 0
|
|
||||||
minutes = 0
|
|
||||||
|
|
||||||
def __init__(self, count, minutes):
|
def __init__(self, count, minutes):
|
||||||
|
self.ips = {}
|
||||||
self.count = count
|
self.count = count
|
||||||
self.minutes = minutes
|
self.minutes = minutes
|
||||||
|
|
||||||
|
|||||||
-24
@@ -9,30 +9,6 @@ from fastapi import UploadFile
|
|||||||
import settings
|
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:
|
class FileSystemStorage:
|
||||||
DATA_ROOT = Path(settings.DATA_ROOT)
|
DATA_ROOT = Path(settings.DATA_ROOT)
|
||||||
STATIC_URL = settings.STATIC_URL
|
STATIC_URL = settings.STATIC_URL
|
||||||
|
|||||||
+10
-7
@@ -397,20 +397,23 @@
|
|||||||
this.code = value;
|
this.code = value;
|
||||||
},
|
},
|
||||||
checkFile: function (file) {
|
checkFile: function (file) {
|
||||||
if (!this.enable) {
|
if (!this.enableUpload) {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: '上传功能已关闭',
|
message: '上传功能已关闭',
|
||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
});
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (file.size > this.fileSizeLimit) {
|
if (file != null) {
|
||||||
this.$message({
|
if (file.size > this.fileSizeLimit) {
|
||||||
message: `文件大小不能超过${this.fileSizeLimit/1024/1024}MB`,
|
this.$message({
|
||||||
type: 'error'
|
message: `文件大小不能超过${this.fileSizeLimit/1024/1024}MB`,
|
||||||
});
|
type: 'error'
|
||||||
return false
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
toUploadData: function () {
|
toUploadData: function () {
|
||||||
if (this.uploadData.text === '' && this.uploadData.file === null) {
|
if (this.uploadData.text === '' && this.uploadData.file === null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user