
    9Cg                        d dl mZmZmZmZmZmZmZmZm	Z	 d dl
mZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZ  G d de          Z G d d          Z ed          ZdedefdZdS )    )	AnyBinaryIOCallableDictIterableOptionalTypeTypeVarcast)PYDANTIC_V2
CoreSchemaGetJsonSchemaHandlerJsonSchemaValue"with_info_plain_validator_function)URL)Address)FormData)Headers)QueryParams)State)
UploadFile)	AnnotatedDocc                       e Zd ZU dZee ed          f         ed<   eee	          ed          f         ed<   eee
          ed          f         ed<   ee ed          f         ed	<   eee	          ed
          f         ed<   dee ed          f         ddf fdZ	 d'dee
 ed          f         def fdZdee
 ed          f         ddf fdZd( fdZeded          deedef                  fd            Zeded          dedefd            Zedededd fd            Zesed ee	ef         ddfd!            Zed"ed#edefd$            Zed%ee         d#eegef         defd&            Z  xZ!S ))r   aA  
    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).filezThe original file name.filenamezThe size of the file in bytes.sizezThe headers of the request.headersz2The content type of the request, from the headers.content_typedatazA
                The bytes to write to the file.
                returnNc                 V   K   t                                          |           d{V S )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     H/var/www/api/venv/lib/python3.11/site-packages/fastapi/datastructures.pyr$   zUploadFile.writeK   s1      $ WW]]4(((((((((    zL
                The number of bytes to read from the file.
                c                 V   K   t                                          |           d{V S )z|
        Read some bytes from the file.

        To be awaitable, compatible with async, this is run in threadpool.
        N)r#   read)r%   r   r&   s     r'   r+   zUploadFile.read_   s1        WW\\$'''''''''r(   offsetzO
                The position in bytes to seek to in the file.
                c                 V   K   t                                          |           d{V S )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)r%   r,   r&   s     r'   r.   zUploadFile.seekq   s1      $ WW\\&)))))))))r(   c                 T   K   t                                                       d{V S )zm
        Close the file.

        To be awaitable, compatible with async, this is run in threadpool.
        N)r#   close)r%   r&   s    r'   r0   zUploadFile.close   s-       WW]]__$$$$$$$r(   cls.c              #      K   | j         V  d S N)validate)r1   s    r'   __get_validators__zUploadFile.__get_validators__   s      lr(   vc                 n    t          |t                    st          dt          |                     |S NzExpected UploadFile, received: )
isinstanceStarletteUploadFile
ValueErrortype)r1   r6   s     r'   r4   zUploadFile.validate   s8    !011 	JHtAwwHHIIIr(   _UploadFile__input_value_c                     t          |t                    st          dt          |                     t	          t
          |          S r8   )r9   r:   r;   r<   r   r   )r1   r=   r>   s      r'   	_validatezUploadFile._validate   sE    -)<== 	VTtM?R?RTTUUUJ...r(   field_schemac                 6    |                     ddd           d S Nstringbinary)r<   format)update)r1   rA   s     r'   __modify_schema__zUploadFile.__modify_schema__   s$    X F FGGGGGr(   core_schemahandlerc                     dddS rC    )r1   rI   rJ   s      r'   __get_pydantic_json_schema__z'UploadFile.__get_pydantic_json_schema__   s     !H555r(   sourcec                 *    t          | j                  S r3   )r   r@   )r1   rN   rJ   s      r'   __get_pydantic_core_schema__z'UploadFile.__get_pydantic_core_schema__   s     2#-@@@r(   )r)   )r!   N)"__name__
__module____qualname____doc__r   r   r   __annotations__r   strintr   bytesr$   r+   r.   r0   classmethodr	   r   r   r   r5   r4   r@   r   r   rH   r   r   r   rM   rP   __classcell__)r&   s   @r'   r   r      s         B :;;	=    ss+D'E'EEFFFF
HSM33'G#H#HH
IIIIw$A B BBCCCCssOPPP   )C 
) 
) ) ) ) ) ): ( (C 
( 
( ( ( ( ( ($*C 
* 
* * * * * *(% % % % % % \ 2 xc@R7S    [ d<( S S    [
 /c /c /l / / / [/
  H		Hc3h 	HD 	H 	H 	H 
	H 6$6/C6	6 6 6 [6
 A#YA)13%2C)DA	A A A [A A A A Ar(   r   c                   :    e Zd ZdZdefdZdefdZdedefdZ	dS )	DefaultPlaceholderz
    You shouldn't use this class directly.

    It's used internally to recognize when a default value has been overwritten, even
    if the overridden default value was truthy.
    valuec                     || _         d S r3   r]   )r%   r]   s     r'   __init__zDefaultPlaceholder.__init__   s    


r(   r!   c                 *    t          | j                  S r3   )boolr]   )r%   s    r'   __bool__zDefaultPlaceholder.__bool__   s    DJr(   oc                 L    t          |t                    o|j        | j        k    S r3   )r9   r\   r]   )r%   rd   s     r'   __eq__zDefaultPlaceholder.__eq__   s!    !/00JQW
5JJr(   N)
rQ   rR   rS   rT   r   r`   rb   rc   objectrf   rL   r(   r'   r\   r\      s~         c     $        K K4 K K K K K Kr(   r\   DefaultTyper]   r!   c                      t          |           S )z
    You shouldn't use this function directly.

    It's used internally to recognize when a default value has been overwritten, even
    if the overridden default value was truthy.
    )r\   r_   s    r'   Defaultrj      s     e$$$r(   N)typingr   r   r   r   r   r   r	   r
   r   fastapi._compatr   r   r   r   r   starlette.datastructuresr   r   r   r   r   r   r   r:   typing_extensionsr   r   r\   rh   rj   rL   r(   r'   <module>ro      s  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
              0 / / / / / 7 7 7 7 7 7 9 9 9 9 9 9 7 7 7 7 7 7 ? ? ? ? ? ? 3 3 3 3 3 3 F F F F F F , , , , , , , ,OA OA OA OA OA$ OA OA OAdK K K K K K K K$ gm$$%; %; % % % % % %r(   