Files
cms-website/.deps_siteforge_v812/fastapi/__pycache__/datastructures.cpython-312.pyc
T

97 lines
7.0 KiB
Plaintext
Raw Normal View History

Ë
ñÅÙjUãóê—ddlmZddlmZmZmZmZmZmZm Z ddl
m Z ddl m
Z
ddlmZddlmZddlmZddlmZdd lmZdd
lmZdd lmZGd „d
e«ZGd„d«Zed«Zdedefd„Zy)é)ÚMapping)Ú AnnotatedÚAnyÚBinaryIOÚCallableÚOptionalÚTypeVarÚcast)ÚDoc)ÚGetJsonSchemaHandler)ÚURL)ÚAddress)ÚFormData)ÚHeaders)Ú QueryParams)ÚState)Ú
UploadFilec óeZdZUdZeeed«fed<eee ed«fed<eee
ed«fed<ee ed«fed <eee ed
«fed <d ee ed
«fddfˆfd„ Z
ddee
ed«fde fˆfd„
Zdee
ed«fddfˆfd„ Zd ˆfd„ Zedededdfd„«Zedee efdedee effd„«Zedeedeegee effdee effd„«ZˆxZS)!raA
A file uploaded in a request.
Define it as a *path operation function* (or dependency) parameter.
If you are using a regular `def` function, you can use the `upload_file.file`
attribute to access the raw standard Python file (blocking, not async), useful and
needed for non-async code.
Read more about it in the
[FastAPI docs for Request Files](https://fastapi.tiangolo.com/tutorial/request-files/).
## Example
```python
from typing import Annotated
from fastapi import FastAPI, File, UploadFile
app = FastAPI()
@app.post("/files/")
async def create_file(file: Annotated[bytes, File()]):
return {"file_size": len(file)}
@app.post("/uploadfile/")
async def create_upload_file(file: UploadFile):
return {"filename": file.filename}
```
z,The standard Python file object (non-async).ÚfilezThe original file name.ÚfilenamezThe size of the file in bytes.ÚsizezThe headers of the request.Úheadersz2The content type of the request, from the headers.Ú content_typeÚdatazA
The bytes to write to the file.
ÚreturnNcƒó>•K—t‰|�|«ƒd{–—†S7Œ­w)zÆ
Write some bytes to the file.
You normally wouldn't use this from a file you read in a request.
To be awaitable, compatible with async, this is run in threadpool.
N)ÚsuperÚwrite)ÚselfrÚ __class__s €úZC:\Users\30997\AppData\Local\Temp\pip-target-6g32zz5s\lib\python\fastapi/datastructures.pyrzUploadFile.writeDsøèø€ô$‘W‘] 4Ó(×(Ð(Ð(úó ƒ–—zL
The number of bytes to read from the file.
cƒó>•K—t‰|�|«ƒd{–—†S7Œ­w)z|
Read some bytes from the file.
To be awaitable, compatible with async, this is run in threadpool.
N)rÚread)rrr s €r!r$zUploadFile.readXsøèø€ô ‘W‘\ $Ó'×'Ð'Ð'úr"ÚoffsetzO
The position in bytes to seek to in the file.
cƒó>•K—t‰|�|«ƒd{–—†S7Œ­w)z¾
Move to a position in the file.
Any next read or write will be done from that position.
To be awaitable, compatible with async, this is run in threadpool.
N)rÚseek)rr%r s €r!r'zUploadFile.seekjsøèø€ô$‘W‘\ &Ó)×)Ð)Ð)úr"cƒó<•K—t‰|�«ƒd{–—†S7Œ­w)zm
Close the file.
To be awaitable, compatible with async, this is run in threadpool.
N)rÚclose)rr s €r!r)zUploadFile.close~søèø€ô ‘W‘]“_×$Ð$Ð$ús ƒ•–Ú_UploadFile__input_valueÚ_cóp—t|t«stdt|«›�«‚t t
|«S)NzExpected UploadFile, received: )Ú
isinstanceÚStarletteUploadFileÚ
ValueErrorÚtyper
r)Úclsr*r+s r!Ú _validatezUploadFile._validate†s3€ä˜-Ô)<Ô=ÜÐ>¼tÀMÓ?RÐ>SÐTÓUÐ UÜ”J 
Ó.Ð.óÚ core_schemaÚhandlercó —dddœS)NÚstringÚbinary)r0Úformat©)r1r4r5s r!Ú__get_pydantic_json_schema__z'UploadFile.__get_pydantic_json_schema__Œs€ð!¨HÑ5Ð5r3Úsourcecó2—ddlm}||j«S)Né)Ú"with_info_plain_validator_function)Ú
_compat.v2r?r2)r1r<r5r?s r!Ú__get_pydantic_core_schema__z'UploadFile.__get_pydantic_core_schema__’s€õ Cá1°#·-±-Ó@Ð@r3)éÿÿÿÿ)rN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrr Ú__annotations__rÚstrÚintrÚbytesrr$r'r)Ú classmethodrr2rr Údictr;r0rrAÚ
__classcell__)r s@r!rrsêø…ñðB ØÙ Ð :Ó;ð =ñ ó𘠙
¡sÐ+DÓ'EÐEÑFÓFØ
�H˜S‘M¡3Ð'GÓ#HÐHÑ
IÓIØ
�w¡Ð$AÓ BÐBÑ
CÓCØØ�‰
‘sÐOÓPÐPñóð)àØ Ù ðó
ð
ñ
ð)ð
õ)ð:
ñ(àØ Ù ðó
ð
ñ
ð(ð
õ(ð$*àØ Ù ðó
ð
ñ