Ë
    ¹ûàg  ã                   óê   — d Z ddlZddlmZ ddlmZ ddlmZmZ ddl	m
Z
 g d¢Z G d„ d	e«      Z G d
„ de«      Z G d„ de«      Z G d„ de«      Z G d„ d«      Z G d„ de«      Z G d„ de«      Zd„ Zy)zH
Base file upload handler classes, and the built-in concrete subclasses
é    N)ÚBytesIO)Úsettings)ÚInMemoryUploadedFileÚTemporaryUploadedFile©Úimport_string)ÚUploadFileExceptionÚ
StopUploadÚSkipFileÚFileUploadHandlerÚTemporaryFileUploadHandlerÚMemoryFileUploadHandlerÚload_handlerÚStopFutureHandlersc                   ó   — e Zd ZdZy)r	   z6
    Any error having to do with uploading files.
    N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    ú]/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/django/core/files/uploadhandler.pyr	   r	      ó   „ ñð 	r   r	   c                   ó   — e Zd ZdZdd„Zd„ Zy)r
   z=
    This exception is raised when an upload must abort.
    c                 ó   — || _         y)zÒ
        If ``connection_reset`` is ``True``, Django knows will halt the upload
        without consuming the rest of the upload. This will cause the browser to
        show a "connection reset" error.
        N©Úconnection_reset)Úselfr   s     r   Ú__init__zStopUpload.__init__%   s   € ð !1ˆÕr   c                 ó   — | j                   ryy)Nz StopUpload: Halt current upload.z,StopUpload: Consume request data, then halt.r   ©r   s    r   Ú__str__zStopUpload.__str__-   s   € Ø× Ò Ø5àAr   N)F)r   r   r   r   r    r#   r   r   r   r
   r
       s   „ ñó1óBr   r
   c                   ó   — e Zd ZdZy)r   zX
    This exception is raised by an upload handler that wants to skip a given file.
    Nr   r   r   r   r   r   4   r   r   r   c                   ó   — e Zd ZdZy)r   z”
    Upload handlers that have handled a file and do not want future handlers to
    run should raise this exception instead of returning None.
    Nr   r   r   r   r   r   <   s   „ ñð
 	r   r   c                   óJ   — e Zd ZdZdZdd„Z	 dd„Z	 	 dd„Zd„ Zd„ Z	d	„ Z
d
„ Zy)r   z3
    Base class for streaming upload handlers.
    i   Nc                 óX   — d | _         d | _        d | _        d | _        d | _        || _        y ©N)Ú	file_nameÚcontent_typeÚcontent_lengthÚcharsetÚcontent_type_extraÚrequest)r   r.   s     r   r    zFileUploadHandler.__init__L   s/   € ØˆŒØ ˆÔØ"ˆÔØˆŒØ"&ˆÔØˆ�r   c                  ó   — y)aÆ  
        Handle the raw input from the client.

        Parameters:

            :input_data:
                An object that supports reading via .read().
            :META:
                ``request.META``.
            :content_length:
                The (integer) value of the Content-Length header from the
                client.
            :boundary: The boundary from the Content-Type header. Be sure to
                prepend two '--'.
        Nr   ©r   Ú
input_dataÚMETAr+   ÚboundaryÚencodings         r   Úhandle_raw_inputz"FileUploadHandler.handle_raw_inputT   s   € ð$ 	r   c                 óX   — || _         || _        || _        || _        || _        || _        y)z½
        Signal that a new file has been started.

        Warning: As with any data from the client, you should not trust
        content_length (and sometimes won't even get it).
        N)Ú
field_namer)   r*   r+   r,   r-   )r   r7   r)   r*   r+   r,   r-   s          r   Únew_filezFileUploadHandler.new_fileh   s1   € ð %ˆŒØ"ˆŒØ(ˆÔØ,ˆÔØˆŒØ"4ˆÕr   c                 ó   — t        d«      ‚)z{
        Receive data from the streamed upload parser. ``start`` is the position
        in the file of the chunk.
        zJsubclasses of FileUploadHandler must provide a receive_data_chunk() method©ÚNotImplementedError©r   Úraw_dataÚstarts      r   Úreceive_data_chunkz$FileUploadHandler.receive_data_chunk~   s   € ô
 "ØXó
ð 	
r   c                 ó   — t        d«      ‚)zÆ
        Signal that a file has completed. File size corresponds to the actual
        size accumulated by all the chunks.

        Subclasses should return a valid ``UploadedFile`` object.
        zEsubclasses of FileUploadHandler must provide a file_complete() methodr:   ©r   Ú	file_sizes     r   Úfile_completezFileUploadHandler.file_complete‡   s   € ô "ØSó
ð 	
r   c                  ó   — y)zƒ
        Signal that the upload is complete. Subclasses should perform cleanup
        that is necessary for this handler.
        Nr   r"   s    r   Úupload_completez!FileUploadHandler.upload_complete’   ó   € ð
 	r   c                  ó   — y)z‡
        Signal that the upload was interrupted. Subclasses should perform
        cleanup that is necessary for this handler.
        Nr   r"   s    r   Úupload_interruptedz$FileUploadHandler.upload_interrupted™   rF   r   r(   )NN)r   r   r   r   Ú
chunk_sizer    r5   r8   r?   rC   rE   rH   r   r   r   r   r   E   s@   „ ñð €Jóð DHóð4 Øó5ò,
ò	
òór   r   c                   ó4   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zd„ Zˆ xZS )r   zA
    Upload handler that streams data into a temporary file.
    c                 óœ   •— t        ‰| �  |i |¤Ž t        | j                  | j                  d| j
                  | j                  «      | _        y)zK
        Create the file object to append to as data is coming in.
        r   N)Úsuperr8   r   r)   r*   r,   r-   Úfile©r   ÚargsÚkwargsÚ	__class__s      €r   r8   z#TemporaryFileUploadHandler.new_file¦   sB   ø€ ô 	‰Ñ˜$Ð) &Ò)Ü)Ø�N‰N˜D×-Ñ-¨q°$·,±,À×@WÑ@Wó
ˆ�	r   c                 ó:   — | j                   j                  |«       y r(   )rM   Úwriter<   s      r   r?   z-TemporaryFileUploadHandler.receive_data_chunk¯   s   € Ø�	‰	�‰˜Õ!r   c                 ór   — | j                   j                  d«       || j                   _        | j                   S )Nr   )rM   ÚseekÚsizerA   s     r   rC   z(TemporaryFileUploadHandler.file_complete²   s'   € Ø�	‰	�‰�qÔØ"ˆ�	‰	ŒØ�y‰yÐr   c                 óÐ   — t        | d«      rK| j                  j                  «       }	 | j                  j                  «        t	        j
                  |«       y y # t        $ r Y y w xY w)NrM   )ÚhasattrrM   Útemporary_file_pathÚcloseÚosÚremoveÚFileNotFoundError)r   Útemp_locations     r   rH   z-TemporaryFileUploadHandler.upload_interrupted·   sV   € Ü�4˜Ô Ø ŸI™I×9Ñ9Ó;ˆMðØ—	‘	—‘Ô!Ü—	‘	˜-Õ(ð	 !øô
 %ò Ùðús   ¨/A Á	A%Á$A%)	r   r   r   r   r8   r?   rC   rH   Ú__classcell__©rQ   s   @r   r   r   ¡   s   ø„ ñô
ò"òö
r   r   c                   ó8   ‡ — e Zd ZdZ	 dd„Zˆ fd„Zd„ Zd„ Zˆ xZS )r   zS
    File upload handler to stream uploads into memory (used for small files).
    c                 ó4   — |t         j                  k  | _        y)zf
        Use the content_length to signal whether or not this handler should be
        used.
        N)r   ÚFILE_UPLOAD_MAX_MEMORY_SIZEÚ	activatedr0   s         r   r5   z(MemoryFileUploadHandler.handle_raw_inputÆ   s   € ð (¬8×+OÑ+OÑOˆ�r   c                 ón   •— t        ‰| �  |i |¤Ž | j                  rt        «       | _        t        «       ‚y r(   )rL   r8   rd   r   rM   r   rN   s      €r   r8   z MemoryFileUploadHandler.new_fileÑ   s3   ø€ Ü‰Ñ˜$Ð) &Ò)Ø�>Š>Ü›	ˆDŒIÜ$Ó&Ð&ð r   c                 óV   — | j                   r| j                  j                  |«       y|S )z!Add the data to the BytesIO file.N)rd   rM   rS   r<   s      r   r?   z*MemoryFileUploadHandler.receive_data_chunk×   s   € à�>Š>Ø�I‰I�O‰O˜HÕ%àˆOr   c           	      óî   — | j                   sy| j                  j                  d«       t        | j                  | j                  | j
                  | j                  || j                  | j                  ¬«      S )z2Return a file object if this handler is activated.Nr   )rM   r7   Únamer*   rV   r,   r-   )	rd   rM   rU   r   r7   r)   r*   r,   r-   rA   s     r   rC   z%MemoryFileUploadHandler.file_completeÞ   sZ   € à�~Š~Øà�	‰	�‰�qÔÜ#Ø—‘Ø—‘Ø—‘Ø×*Ñ*ØØ—L‘LØ#×6Ñ6ô
ð 	
r   r(   )	r   r   r   r   r5   r8   r?   rC   r_   r`   s   @r   r   r   Á   s$   ø„ ñð
 DHó	Pô'òö
r   r   c                 ó$   —  t        | «      |i |¤ŽS )al  
    Given a path to a handler, return an instance of that handler.

    E.g.::
        >>> from django.http import HttpRequest
        >>> request = HttpRequest()
        >>> load_handler(
        ...     'django.core.files.uploadhandler.TemporaryFileUploadHandler',
        ...     request,
        ... )
        <TemporaryFileUploadHandler object at 0x...>
    r   )ÚpathrO   rP   s      r   r   r   ï   s   € ð Œ=˜Ó Ð/¨Ñ/Ð/r   )r   r[   Úior   Údjango.confr   Údjango.core.files.uploadedfiler   r   Údjango.utils.module_loadingr   Ú__all__Ú	Exceptionr	   r
   r   r   r   r   r   r   r   r   r   ú<module>rq      s…   ðñó 
Ý å  ß VÝ 5ò	€ô	˜)ô 	ôBÐ$ô Bô(	Ð"ô 	ô	Ð,ô 	÷Yñ YôxÐ!2ô ô@+
Ð/ô +
ó\0r   