You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
508 B
18 lines
508 B
import os
|
|
from fastapi import UploadFile
|
|
|
|
|
|
class CommonService:
|
|
"""
|
|
通用模块服务层
|
|
"""
|
|
|
|
@classmethod
|
|
def upload_service(cls, path: str, task_path: str, upload_id: str, file: UploadFile):
|
|
|
|
filepath = os.path.join(path, task_path, upload_id, f'{file.filename}')
|
|
with open(filepath, 'wb') as f:
|
|
# 流式写出大型文件,这里的10代表10MB
|
|
for chunk in iter(lambda: file.file.read(1024 * 1024 * 10), b''):
|
|
f.write(chunk)
|
|
|
|
|