统一创建FileCodes记录,返回code
(
file_name: str,
file_size: int,
file_path: str,
expire_value: int,
expire_style: str,
**extra_fields,
)
| 55 | |
| 56 | @staticmethod |
| 57 | async def create_file_record( |
| 58 | file_name: str, |
| 59 | file_size: int, |
| 60 | file_path: str, |
| 61 | expire_value: int, |
| 62 | expire_style: str, |
| 63 | **extra_fields, |
| 64 | ) -> str: |
| 65 | """统一创建FileCodes记录,返回code""" |
| 66 | expired_at, expired_count, used_count, code = await get_expire_info( |
| 67 | expire_value, expire_style |
| 68 | ) |
| 69 | prefix, suffix = os.path.splitext(file_name) |
| 70 | |
| 71 | await FileCodes.create( |
| 72 | code=code, |
| 73 | prefix=prefix, |
| 74 | suffix=suffix, |
| 75 | uuid_file_name=file_name, |
| 76 | file_path=file_path, |
| 77 | size=file_size, |
| 78 | expired_at=expired_at, |
| 79 | expired_count=expired_count, |
| 80 | used_count=used_count, |
| 81 | **extra_fields, |
| 82 | ) |
| 83 | return code |
| 84 | |
| 85 | |
| 86 | async def validate_file_size(file: UploadFile, max_size: int) -> int: |
no test coverage detected