HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/django/core/files/__pycache__/uploadhandler.cpython-310.pyc
o

�a.�@s�dZddlZddlmZddlmZddlmZmZddl	m
Z
gd�ZGdd	�d	e�Z
Gd
d�de
�ZGdd
�d
e
�ZGdd�de
�ZGdd�d�ZGdd�de�ZGdd�de�Zdd�ZdS)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@�eZdZdZdS)rz6
    Any error having to do with uploading files.
    N��__name__�
__module__�__qualname__�__doc__�rr�A/usr/lib/python3/dist-packages/django/core/files/uploadhandler.pyr�rc@s"eZdZdZddd�Zdd�ZdS)	r	z=
    This exception is raised when an upload must abort.
    FcCs
||_dS)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)�selfrrrr�__init__s
zStopUpload.__init__cCs|jrdSdS)Nz StopUpload: Halt current upload.z,StopUpload: Consume request data, then halt.r�rrrr�__str__'szStopUpload.__str__N)F)rrrrrrrrrrr	s
r	c@r)r
zX
    This exception is raised by an upload handler that wants to skip a given file.
    Nrrrrrr
.rr
c@r)rz�
    Upload handlers that have handled a file and do not want future handlers to
    run should raise this exception instead of returning None.
    Nrrrrrr5src@sReZdZdZdZddd�Zddd�Zddd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)rz3
    Base class for streaming upload handlers.
    iNcCs(d|_d|_d|_d|_d|_||_dS�N)�	file_name�content_type�content_length�charset�content_type_extra�request)rr%rrrrCs
zFileUploadHandler.__init__cC�dS)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�encodingrrr�handle_raw_inputKsz"FileUploadHandler.handle_raw_inputcCs(||_||_||_||_||_||_dS)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$)rr-r r!r"r#r$rrr�new_file]s
zFileUploadHandler.new_filecC�td��)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�startrrr�receive_data_chunkksz$FileUploadHandler.receive_data_chunkcCr/)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() methodr0�r�	file_sizerrr�
file_completerszFileUploadHandler.file_completecCr&)z�
        Signal that the upload is complete. Subclasses should perform cleanup
        that is necessary for this handler.
        Nrrrrr�upload_complete{�z!FileUploadHandler.upload_completecCr&)z�
        Signal that the upload was interrupted. Subclasses should perform
        cleanup that is necessary for this handler.
        Nrrrrr�upload_interrupted�r:z$FileUploadHandler.upload_interruptedr)NN)rrrr�
chunk_sizerr,r.r5r8r9r;rrrrr=s


	rcs8eZdZdZ�fdd�Zdd�Zdd�Zdd	�Z�ZS)
rzA
    Upload handler that streams data into a temporary file.
    cs0t�j|i|��t|j|jd|j|j�|_dS)zK
        Create the file object to append to as data is coming in.
        rN)�superr.rr r!r#r$�file�r�args�kwargs��	__class__rrr.�sz#TemporaryFileUploadHandler.new_filecCs|j�|�dSr)r>�writer2rrrr5�sz-TemporaryFileUploadHandler.receive_data_chunkcCs|j�d�||j_|jS)Nr)r>�seek�sizer6rrrr8�sz(TemporaryFileUploadHandler.file_completecCsHt|d�r"|j��}z
|j��t�|�WdSty!YdSwdS)Nr>)�hasattrr>�temporary_file_path�close�os�remove�FileNotFoundError)r�
temp_locationrrrr;�s


��z-TemporaryFileUploadHandler.upload_interrupted)	rrrrr.r5r8r;�
__classcell__rrrBrr�srcs:eZdZdZddd�Z�fdd�Zdd�Zd	d
�Z�ZS)r
zS
    File upload handler to stream uploads into memory (used for small files).
    NcCs|tjk|_dS)zf
        Use the content_length to signal whether or not this handler should be
        used.
        N)r�FILE_UPLOAD_MAX_MEMORY_SIZE�	activatedr'rrrr,�sz(MemoryFileUploadHandler.handle_raw_inputcs*t�j|i|��|jrt�|_t��dSr)r=r.rPrr>rr?rBrrr.�s
�z MemoryFileUploadHandler.new_filecCs|jr|j�|�dS|S)z!Add the data to the BytesIO file.N)rPr>rDr2rrrr5�sz*MemoryFileUploadHandler.receive_data_chunkc	Cs8|jsdS|j�d�t|j|j|j|j||j|jd�S)z2Return a file object if this handler is activated.Nr)r>r-�namer!rFr#r$)	rPr>rErr-r r!r#r$r6rrrr8�s�z%MemoryFileUploadHandler.file_completer)	rrrrr,r.r5r8rNrrrBrr
�s
	r
cOst|�|i|��S)a=
    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@rArrrr�s
r)rrJ�ior�django.confr�django.core.files.uploadedfilerr�django.utils.module_loadingr�__all__�	Exceptionrr	r
rrrr
rrrrr�<module>sM,