ó
    ¼Rj  ã                   óê   • S r SSKrSSKJr  SSKJr  SSKJrJr  SSK	J
r
  / SQr " S S	\5      r " S
 S\5      r " S S\5      r " S S\5      r " S S5      r " S S\5      r " S S\5      rS rg)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                   ó   • \ rS rSrSrSrg)r	   é   z.
Any error having to do with uploading files.
© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    ÚKD:\diplom_project\venv\Lib\site-packages\django/core/files/uploadhandler.pyr	   r	      ó   † ñò 	r   r	   c                   ó(   • \ rS rSrSrSS jrS rSrg)r
   é   z5
This exception is raised when an upload must abort.
c                 ó   • Xl         g)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__ÚStopUpload.__init__$   s
   € ð !1Õr   c                 ó(   • U R                   (       a  gg)Nz StopUpload: Halt current upload.z,StopUpload: Consume request data, then halt.r!   ©r#   s    r   Ú__str__ÚStopUpload.__str__,   s   € Ø× × Ø5àAr   r!   N)F)r   r   r   r   r   r$   r(   r   r   r   r   r
   r
      s   † ñô1õBr   r
   c                   ó   • \ rS rSrSrSrg)r   é3   zP
This exception is raised by an upload handler that wants to skip a given file.
r   Nr   r   r   r   r   r   3   r   r   r   c                   ó   • \ rS rSrSrSrg)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.
r   Nr   r   r   r   r   r   ;   s   † ñò
 	r   r   c                   óX   • \ rS rSrSrSrSS jr SS jr  SS jrS r	S	 r
S
 rS rSrg)r   éD   z+
Base class for streaming upload handlers.
i   Nc                 óV   • S U l         S U l        S U l        S U l        S U l        Xl        g ©N)Ú	file_nameÚcontent_typeÚcontent_lengthÚcharsetÚcontent_type_extraÚrequest)r#   r7   s     r   r$   ÚFileUploadHandler.__init__K   s-   € ØˆŒØ ˆÔØ"ˆÔØˆŒØ"&ˆÔØ�r   c                 ó   • g)af  
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ÚMETAr4   ÚboundaryÚencodings         r   Úhandle_raw_inputÚ"FileUploadHandler.handle_raw_inputS   s   € ð$ 	r   c                 óL   • Xl         X l        X0l        X@l        XPl        X`l        g)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_namer2   r3   r4   r5   r6   )r#   rB   r2   r3   r4   r5   r6   s          r   Únew_fileÚFileUploadHandler.new_fileg   s%   € ð %ŒØ"ŒØ(ÔØ,ÔØŒØ"4Õr   c                 ó   • [        S5      e)zc
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_chunkÚ$FileUploadHandler.receive_data_chunk}   s   € ô
 "ØXó
ð 	
r   c                 ó   • [        S5      e)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() methodrF   ©r#   Ú	file_sizes     r   Úfile_completeÚFileUploadHandler.file_complete†   s   € ô "ØSó
ð 	
r   c                 ó   • g)zk
Signal that the upload is complete. Subclasses should perform cleanup
that is necessary for this handler.
Nr   r'   s    r   Úupload_completeÚ!FileUploadHandler.upload_complete‘   ó   € ð
 	r   c                 ó   • g)zo
Signal that the upload was interrupted. Subclasses should perform
cleanup that is necessary for this handler.
Nr   r'   s    r   Úupload_interruptedÚ$FileUploadHandler.upload_interrupted˜   rU   r   )r5   r4   r3   r6   rB   r2   r7   r1   )NN)r   r   r   r   r   Ú
chunk_sizer$   r?   rC   rK   rP   rS   rW   r   r   r   r   r   r   D   s@   † ñð €Jôð DHôð4 Øô5ò,
ò	
òõr   r   c                   ó>   ^ • \ rS rSrSrU 4S jrS rS rS rSr	U =r
$ )r   é    z9
Upload handler that streams data into a temporary file.
c                 óž   >• [         TU ]  " U0 UD6  [        U R                  U R                  SU R
                  U R                  5      U l        g)z;
Create the file object to append to as data is coming in.
r   N)ÚsuperrC   r   r2   r3   r5   r6   Úfile©r#   ÚargsÚkwargsÚ	__class__s      €r   rC   Ú#TemporaryFileUploadHandler.new_file¥   sB   ø€ ô 	‰Ò˜$Ð) &Ò)Ü)Ø�N‰N˜D×-Ñ-¨q°$·,±,À×@WÑ@Wó
ˆ�	r   c                 ó:   • U R                   R                  U5        g r1   )r^   ÚwriterH   s      r   rK   Ú-TemporaryFileUploadHandler.receive_data_chunk®   s   € Ø�	‰	�‰˜Õ!r   c                 óp   • U R                   R                  S5        XR                   l        U R                   $ )Nr   )r^   ÚseekÚsizerN   s     r   rP   Ú(TemporaryFileUploadHandler.file_complete±   s%   € Ø�	‰	�‰�qÔØ"�	‰	ŒØ�y‰yÐr   c                 óÞ   • [        U S5      (       aL  U R                  R                  5       n U R                  R                  5         [        R
                  " U5        g g ! [         a     g f = f)Nr^   )Úhasattrr^   Útemporary_file_pathÚcloseÚosÚremoveÚFileNotFoundError)r#   Útemp_locations     r   rW   Ú-TemporaryFileUploadHandler.upload_interrupted¶   sY   € Ü�4˜× Ñ Ø ŸI™I×9Ñ9Ó;ˆMðØ—	‘	—‘Ô!Ü—	’	˜-Õ(ð	 !øô
 %ó Ùðús   ­0A Á
A,Á+A,)r^   )r   r   r   r   r   rC   rK   rP   rW   r   Ú__classcell__©rb   s   @r   r   r       s!   ø† ñõ
ò"ò÷
ð r   r   c                   óD   ^ • \ rS rSrSr SS jrU 4S jrS rS rSr	U =r
$ )	r   éÀ   zK
File upload handler to stream uploads into memory (used for small files).
c                 ó4   • U[         R                  :*  U l        g)zN
Use the content_length to signal whether or not this handler should be
used.
N)r   ÚFILE_UPLOAD_MAX_MEMORY_SIZEÚ	activatedr:   s         r   r?   Ú(MemoryFileUploadHandler.handle_raw_inputÅ   s   € ð (¬8×+OÑ+OÑOˆ�r   c                 óz   >• [         TU ]  " U0 UD6  U R                  (       a  [        5       U l        [        5       eg r1   )r]   rC   rz   r   r^   r   r_   s      €r   rC   Ú MemoryFileUploadHandler.new_fileÐ   s3   ø€ Ü‰Ò˜$Ð) &Ò)Ø�>�>Ü›	ˆDŒIÜ$Ó&Ð&ð r   c                 ó`   • U R                   (       a  U R                  R                  U5        gU$ )z!Add the data to the BytesIO file.N)rz   r^   re   rH   s      r   rK   Ú*MemoryFileUploadHandler.receive_data_chunkÖ   s   € à�>�>Ø�I‰I�O‰O˜HÕ%àˆOr   c           
      óò   • U R                   (       d  gU R                  R                  S5        [        U R                  U R                  U R
                  U R                  UU R                  U R                  S9$ )z2Return a file object if this handler is activated.Nr   )r^   rB   Únamer3   ri   r5   r6   )	rz   r^   rh   r   rB   r2   r3   r5   r6   rN   s     r   rP   Ú%MemoryFileUploadHandler.file_completeÝ   sZ   € à�~�~Øà�	‰	�‰�qÔÜ#Ø—‘Ø—‘Ø—‘Ø×*Ñ*ØØ—L‘LØ#×6Ñ6ñ
ð 	
r   )rz   r^   r1   )r   r   r   r   r   r?   rC   rK   rP   r   rt   ru   s   @r   r   r   À   s)   ø† ñð
 DHô	Põ'ò÷
ð 
r   r   c                 ó$   • [        U 5      " U0 UD6$ )aD  
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   )Úpathr`   ra   s      r   r   r   î   s   € ô ˜Ô Ð/¨Ñ/Ð/r   )r   ro   Ú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>r‹      s…   ðñó 
Ý å  ß VÝ 5ò	€ô	˜)ô 	ôBÐ$ô Bô(	Ð"ô 	ô	Ð,ô 	÷Yñ YôxÐ!2ô ô@+
Ð/ô +
ó\0r   