(
text: str = Form(...),
expire_value: int = Form(default=1, gt=0),
expire_style: str = Form(default="day"),
ip: str = Depends(ip_limit["upload"]),
)
| 139 | |
| 140 | @share_api.post("/text/", dependencies=[Depends(share_required_login)]) |
| 141 | async def share_text( |
| 142 | text: str = Form(...), |
| 143 | expire_value: int = Form(default=1, gt=0), |
| 144 | expire_style: str = Form(default="day"), |
| 145 | ip: str = Depends(ip_limit["upload"]), |
| 146 | ): |
| 147 | text_size = len(text.encode("utf-8")) |
| 148 | max_txt_size = 222 * 1024 |
| 149 | if text_size > max_txt_size: |
| 150 | raise HTTPException(status_code=403, detail="内容过多,建议采用文件形式") |
| 151 | |
| 152 | expired_at, expired_count, used_count, code = await get_expire_info( |
| 153 | expire_value, expire_style |
| 154 | ) |
| 155 | await create_file_code( |
| 156 | code=code, |
| 157 | text=text, |
| 158 | expired_at=expired_at, |
| 159 | expired_count=expired_count, |
| 160 | used_count=used_count, |
| 161 | size=len(text), |
| 162 | prefix="Text", |
| 163 | ) |
| 164 | ip_limit["upload"].add_ip(ip) |
| 165 | return APIResponse(detail={"code": code}) |
| 166 | |
| 167 | |
| 168 | @share_api.post("/file/", dependencies=[Depends(share_required_login)]) |
nothing calls this directly
no test coverage detected