Skip to content

Commit c3022bf

Browse files
committed
fix:上传前检测+上传次数限制
1 parent f070bdc commit c3022bf

File tree

3 files changed

+11
-35
lines changed

3 files changed

+11
-35
lines changed

depends.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ async def admin_required(pwd: Union[str, None] = Header(default=None), request:
1616

1717

1818
class IPRateLimit:
19-
ips = {}
20-
count = 0
21-
minutes = 0
22-
2319
def __init__(self, count, minutes):
20+
self.ips = {}
2421
self.count = count
2522
self.minutes = minutes
2623

storage.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,6 @@
99
import settings
1010

1111

12-
class TencentCOS:
13-
def __init__(self, bucket: str, region: str, secret_id: str, secret_key: str):
14-
self.bucket = bucket
15-
self.region = region
16-
self.secret_id = secret_id
17-
self.secret_key = secret_key
18-
19-
def upload(self, file: UploadFile, path: str) -> str:
20-
# 上传文件
21-
pass
22-
23-
def download(self, path: str) -> BinaryIO:
24-
# 下载文件
25-
pass
26-
27-
def delete(self, path: str) -> None:
28-
# 删除文件
29-
pass
30-
31-
def get_url(self, path: str) -> str:
32-
# 获取文件访问链接
33-
pass
34-
35-
3612
class FileSystemStorage:
3713
DATA_ROOT = Path(settings.DATA_ROOT)
3814
STATIC_URL = settings.STATIC_URL

templates/index.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,20 +397,23 @@ <h1 @click="copyText(file.code,0)" style="margin: 0;display: inline;cursor: poin
397397
this.code = value;
398398
},
399399
checkFile: function (file) {
400-
if (!this.enable) {
400+
if (!this.enableUpload) {
401401
this.$message({
402402
message: '上传功能已关闭',
403403
type: 'error'
404404
});
405405
return false
406406
}
407-
if (file.size > this.fileSizeLimit) {
408-
this.$message({
409-
message: `文件大小不能超过${this.fileSizeLimit/1024/1024}MB`,
410-
type: 'error'
411-
});
412-
return false
407+
if (file != null) {
408+
if (file.size > this.fileSizeLimit) {
409+
this.$message({
410+
message: `文件大小不能超过${this.fileSizeLimit/1024/1024}MB`,
411+
type: 'error'
412+
});
413+
return false;
414+
}
413415
}
416+
return true;
414417
},
415418
toUploadData: function () {
416419
if (this.uploadData.text === '' && this.uploadData.file === null) {

0 commit comments

Comments
 (0)