Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/site-packages/s3transfer/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/site-packages/s3transfer/__pycache__/upload.cpython-38.pyc
U

P��g
|�@s�ddlZddlmZddlmZmZddlmZddlm	Z	ddl
mZmZm
Z
mZddlmZmZmZmZGdd	�d	�ZGd
d�d�ZGdd
�d
�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de
�ZGdd�de�ZGdd�de�ZdS)�N)�BytesIO��readable�seekable)�FULL_OBJECT_CHECKSUM_ARGS)�IN_MEMORY_UPLOAD_TAG)�CompleteMultipartUploadTask�CreateMultipartUploadTask�SubmissionTask�Task)�ChunksizeAdjuster�DeferredOpenFile�
get_callbacks�get_filtered_dictc@s.eZdZddd�Zdd�Zdd�Zdd	�Zd
S)�AggregatedProgressCallback�cCs||_||_d|_dS)a�Aggregates progress updates for every provided progress callback

        :type callbacks: A list of functions that accepts bytes_transferred
            as a single argument
        :param callbacks: The callbacks to invoke when threshold is reached

        :type threshold: int
        :param threshold: The progress threshold in which to take the
            aggregated progress and invoke the progress callback with that
            aggregated progress total
        rN)�
_callbacks�
_threshold�_bytes_seen)�self�	callbacks�	threshold�r�>/opt/cppython/lib/python3.8/site-packages/s3transfer/upload.py�__init__"sz#AggregatedProgressCallback.__init__cCs&|j|7_|j|jkr"|��dS�N)rr�_trigger_callbacks)r�bytes_transferredrrr�__call__2sz#AggregatedProgressCallback.__call__cCs|jdkr|��dS)z@Flushes out any progress that has not been sent to its callbacksrN)rr�rrrr�flush7s
z AggregatedProgressCallback.flushcCs"|jD]}||jd�qd|_dS)N)rr)rr)r�callbackrrrr<s
z-AggregatedProgressCallback._trigger_callbacksN)r)�__name__�
__module__�__qualname__rrr rrrrrr!s
rc@sLeZdZdZdd�Zddd�Zddd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)�InterruptReadera�Wrapper that can interrupt reading using an error

    It uses a transfer coordinator to propagate an error if it notices
    that a read is being made while the file is being read from.

    :type fileobj: file-like obj
    :param fileobj: The file-like object to read from

    :type transfer_coordinator: s3transfer.futures.TransferCoordinator
    :param transfer_coordinator: The transfer coordinator to use if the
        reader needs to be interrupted.
    cCs||_||_dSr)�_fileobj�_transfer_coordinator)r�fileobj�transfer_coordinatorrrrrPszInterruptReader.__init__NcCs|jjr|jj�|j�|�Sr)r'�	exceptionr&�read)r�amountrrrr+TszInterruptReader.readrcCs|j�||�dSr)r&�seek)r�where�whencerrrr-^szInterruptReader.seekcCs
|j��Sr)r&�tellrrrrr0aszInterruptReader.tellcCs|j��dSr)r&�closerrrrr1dszInterruptReader.closecCs|Srrrrrr�	__enter__gszInterruptReader.__enter__cOs|��dSr)r1)r�args�kwargsrrr�__exit__jszInterruptReader.__exit__)N)r)r"r#r$�__doc__rr+r-r0r1r2r5rrrrr%Bs



r%c@sfeZdZdZddd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�ZdS)�UploadInputManageraJBase manager class for handling various types of files for uploads

    This class is typically used for the UploadSubmissionTask class to help
    determine the following:

        * How to determine the size of the file
        * How to determine if a multipart upload is required
        * How to retrieve the body for a PutObject
        * How to retrieve the bodies for a set of UploadParts

    The answers/implementations differ for the various types of file inputs
    that may be accepted. All implementations must subclass and override
    public methods from this class.
    NcCs||_||_||_dSr)�_osutilr'�_bandwidth_limiter�r�osutilr)�bandwidth_limiterrrrr~szUploadInputManager.__init__cCstd��dS)aDetermines if the source for the upload is compatible with manager

        :param upload_source: The source for which the upload will pull data
            from.

        :returns: True if the manager can handle the type of source specified
            otherwise returns False.
        zmust implement _is_compatible()N��NotImplementedError��clsZ
upload_sourcerrr�
is_compatible�s
z UploadInputManager.is_compatiblecCstd��dS)a�Whether the body it provides are stored in-memory

        :type operation_name: str
        :param operation_name: The name of the client operation that the body
            is being used for. Valid operation_names are ``put_object`` and
            ``upload_part``.

        :rtype: boolean
        :returns: True if the body returned by the manager will be stored in
            memory. False if the manager will not directly store the body in
            memory.
        z%must implement store_body_in_memory()Nr=�r�operation_namerrr�stores_body_in_memory�s
z(UploadInputManager.stores_body_in_memorycCstd��dS)z�Provides the transfer size of an upload

        :type transfer_future: s3transfer.futures.TransferFuture
        :param transfer_future: The future associated with upload request
        z&must implement provide_transfer_size()Nr=�r�transfer_futurerrr�provide_transfer_size�sz(UploadInputManager.provide_transfer_sizecCstd��dS)a�Determines where a multipart upload is required

        :type transfer_future: s3transfer.futures.TransferFuture
        :param transfer_future: The future associated with upload request

        :type config: s3transfer.manager.TransferConfig
        :param config: The config associated to the transfer manager

        :rtype: boolean
        :returns: True, if the upload should be multipart based on
            configuration and size. False, otherwise.
        z*must implement requires_multipart_upload()Nr=�rrF�configrrr�requires_multipart_upload�s
z,UploadInputManager.requires_multipart_uploadcCstd��dS)a�Returns the body to use for PutObject

        :type transfer_future: s3transfer.futures.TransferFuture
        :param transfer_future: The future associated with upload request

        :type config: s3transfer.manager.TransferConfig
        :param config: The config associated to the transfer manager

        :rtype: s3transfer.utils.ReadFileChunk
        :returns: A ReadFileChunk including all progress callbacks
            associated with the transfer future.
        z$must implement get_put_object_body()Nr=rErrr�get_put_object_body�s
z&UploadInputManager.get_put_object_bodycCstd��dS)aYields the part number and body to use for each UploadPart

        :type transfer_future: s3transfer.futures.TransferFuture
        :param transfer_future: The future associated with upload request

        :type chunksize: int
        :param chunksize: The chunksize to use for this upload.

        :rtype: int, s3transfer.utils.ReadFileChunk
        :returns: Yields the part number and the ReadFileChunk including all
            progress callbacks associated with the transfer future for that
            specific yielded part.
        z)must implement yield_upload_part_bodies()Nr=)rrF�	chunksizerrr�yield_upload_part_bodies�sz+UploadInputManager.yield_upload_part_bodiescCs*t||j�}|jr&|jj||jdd�}|S)NF)�enabled)r%r'r9Zget_bandwith_limited_stream)rr(rrr�
_wrap_fileobj�s�z UploadInputManager._wrap_fileobjcCst|d�}|rt|�gSgS)N�progress)rr)rrFrrrr�_get_progress_callbacks�s

z*UploadInputManager._get_progress_callbackscCsdd�|D�S)NcSsg|]
}|j�qSr)r )�.0r!rrr�
<listcomp>�sz;UploadInputManager._get_close_callbacks.<locals>.<listcomp>r)rZaggregated_progress_callbacksrrr�_get_close_callbacks�sz'UploadInputManager._get_close_callbacks)N)r"r#r$r6r�classmethodrArDrGrJrKrMrOrQrTrrrrr7ns

	r7c@sdeZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�ZdS)�UploadFilenameInputManagerzUpload utility for filenamescCs
t|t�Sr)�
isinstance�strr?rrrrA�sz(UploadFilenameInputManager.is_compatiblecCsdS)NFrrBrrrrD�sz0UploadFilenameInputManager.stores_body_in_memorycCs|j�|j�|jjj��dSr)�metarGr8Z
get_file_size�	call_argsr(rErrrrG�s�z0UploadFilenameInputManager.provide_transfer_sizecCs|jj|jkSr)rY�size�multipart_thresholdrHrrrrJ�sz4UploadFilenameInputManager.requires_multipart_uploadcCsJ|�|�\}}|�|�}|�|�}|�|�}|jj}|jj|||||d�S)N�r(�
chunk_size�full_file_sizer�close_callbacks)�&_get_put_object_fileobj_with_full_sizerOrQrTrYr[r8�#open_file_chunk_reader_from_fileobj)rrFr(�	full_sizerr`r[rrrrK�s�


�z.UploadFilenameInputManager.get_put_object_bodyccs�|jj}|�||�}td|d�D]j}|�|�}|�|�}||d}|j|jjj|||d�\}	}
|�	|	�}	|j
j|	||
||d�}||fVq"dS)N�)�
start_byte�	part_sizer_r])rYr[�_get_num_parts�rangerQrT�'_get_upload_part_fileobj_with_full_sizerZr(rOr8rb)rrFrLr_Z	num_parts�part_numberrr`rer(rcZread_file_chunkrrrrMs*

�


�z3UploadFilenameInputManager.yield_upload_part_bodiescCst|||jjd�}|S)N)Z
open_function)r
r8�open)rr(rerrr�_get_deferred_open_file2s�z2UploadFilenameInputManager._get_deferred_open_filecCs"|jjj}|jj}|�|d�|fS)Nr)rYrZr(r[rl�rrFr(r[rrrra8s
zAUploadFilenameInputManager._get_put_object_fileobj_with_full_sizecKs |d}|d}|�||�|fS)Nrer_)rl)rr(r4rercrrrri=szBUploadFilenameInputManager._get_upload_part_fileobj_with_full_sizecCstt�|jjt|���Sr)�int�math�ceilrYr[�float)rrFrfrrrrgBsz)UploadFilenameInputManager._get_num_partsN)r"r#r$r6rUrArDrGrJrKrMrlrarirgrrrrrV�s
rVc@s<eZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dS)
�UploadSeekableInputManagerz&Upload utility for an open file objectcCst|�ot|�Srrr?rrrrAIsz(UploadSeekableInputManager.is_compatiblecCs|dkrdSdSdS)N�
put_objectFTrrBrrrrDMsz0UploadSeekableInputManager.stores_body_in_memorycCsD|jjj}|��}|�dd�|��}|�|�|j�||�dS)Nr�)rYrZr(r0r-rG)rrFr(Zstart_positionZend_positionrrrrGSs

�z0UploadSeekableInputManager.provide_transfer_sizecKs|�|d�}t|�t|�fS)Nrf)r+r�len)rr(r4�datarrrri`szBUploadSeekableInputManager._get_upload_part_fileobj_with_full_sizecCs"|jjj}|��|jj}||fSr)rYrZr(r0r[rmrrrraos
zAUploadSeekableInputManager._get_put_object_fileobj_with_full_sizeN)
r"r#r$r6rUrArDrGrirarrrrrrFs

rrcsheZdZdZd�fdd�	Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zddd�Zdd�Z
�ZS)�UploadNonSeekableInputManagerz7Upload utility for a file-like object that cannot seek.Ncst��|||�d|_dS)N�)�superr�
_initial_datar:��	__class__rrrzsz&UploadNonSeekableInputManager.__init__cCst|�Sr)rr?rrrrA~sz+UploadNonSeekableInputManager.is_compatiblecCsdS)NTrrBrrrrD�sz3UploadNonSeekableInputManager.stores_body_in_memorycCsdSrrrErrrrG�sz3UploadNonSeekableInputManager.provide_transfer_sizecCsT|jjdk	r|jj|jkS|jjj}|j}|�||d�|_t|j�|krLdSdSdS)NFT)rYr[r\rZr(�_readrzru)rrFrIr(rrrrrJ�s
z7UploadNonSeekableInputManager.requires_multipart_uploadcCs@|�|�}|�|�}|jjj}|�|j|��||�}d|_|Sr)rQrTrYrZr(�
_wrap_datarzr+)rrFrr`r(�bodyrrrrK�s


�z1UploadNonSeekableInputManager.get_put_object_bodyc	cs^|jjj}d}|�|�}|�|�}|d7}|�||�}|s<qZ|�|||�}d}||fVqdS)Nrrd)rYrZr(rQrTr}r~)	rrFrLZfile_objectrjrr`Zpart_contentZpart_objectrrrrM�s


�z6UploadNonSeekableInputManager.yield_upload_part_bodiesTcCsxt|j�dkr|�|�S|t|j�krL|jd|�}|rH|j|d�|_|S|t|j�}|j|�|�}|rtd|_|S)a=
        Reads a specific amount of data from a stream and returns it. If there
        is any data in initial_data, that will be popped out first.

        :type fileobj: A file-like object that implements read
        :param fileobj: The stream to read from.

        :type amount: int
        :param amount: The number of bytes to read from the stream.

        :type truncate: bool
        :param truncate: Whether or not to truncate initial_data after
            reading from it.

        :return: Generator which generates part bodies from the initial data.
        rNrx)rurzr+)rr(r,�truncatervZamount_to_readrrrr}�s
z#UploadNonSeekableInputManager._readcCs,|�t|��}|jj|t|�t|�||d�S)a�
        Wraps data with the interrupt reader and the file chunk reader.

        :type data: bytes
        :param data: The data to wrap.

        :type callbacks: list
        :param callbacks: The callbacks associated with the transfer future.

        :type close_callbacks: list
        :param close_callbacks: The callbacks to be called when closing the
            wrapper for the data.

        :return: Fully wrapped data.
        r])rOrr8rbru)rrvrr`r(rrrr~�s�z(UploadNonSeekableInputManager._wrap_data)N)T)r"r#r$r6rrUrArDrGrJrKrMr}r~�
__classcell__rrr{rrwws

*rwc@s�eZdZdZddgZedgZdddddd	gZddddd	ddgeZd
d�Z	dd
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�UploadSubmissionTaskz.Task for submitting tasks to execute an upload�ChecksumTypeZ
MpuObjectSize�ChecksumAlgorithmZSSECustomerKeyZSSECustomerAlgorithmZSSECustomerKeyMD5ZRequestPayerZExpectedBucketOwnercCsNtttg}|jjj}|D]}|�|�r|Sqtd|�dt|��d���dS)aoRetrieves a class for managing input for an upload based on file type

        :type transfer_future: s3transfer.futures.TransferFuture
        :param transfer_future: The transfer future for the request

        :rtype: class of UploadInputManager
        :returns: The appropriate class to use for managing a specific type of
            input for uploads.
        zInput z
 of type: z is not supported.N)	rVrrrwrYrZr(rA�RuntimeError�type)rrFZupload_manager_resolver_chainr(Zupload_manager_clsrrr�_get_upload_input_manager_clss�


�z2UploadSubmissionTask._get_upload_input_manager_clsNcCsd|�|�||j|�}|jjdkr*|�|�|�||�sL|�||||||�n|�||||||�dS)a�
        :param client: The client associated with the transfer manager

        :type config: s3transfer.manager.TransferConfig
        :param config: The transfer config associated with the transfer
            manager

        :type osutil: s3transfer.utils.OSUtil
        :param osutil: The os utility associated to the transfer manager

        :type request_executor: s3transfer.futures.BoundedExecutor
        :param request_executor: The request executor associated with the
            transfer manager

        :type transfer_future: s3transfer.futures.TransferFuture
        :param transfer_future: The transfer future associated with the
            transfer request that tasks are being submitted for
        N)r�r'rYr[rGrJ�_submit_upload_request�_submit_multipart_request)r�clientrIr;�request_executorrFr<�upload_input_managerrrr�_submit3s:��
��	�zUploadSubmissionTask._submitc

CsX|jj}|�|j�}|�|d�}	|jj|t|j||�|�|j	|j
|d�dd�|	d�dS)Nrs)r�r(�bucket�key�
extra_argsT)r)�main_kwargs�is_final��tag)rYrZ�_extra_put_object_argsr��_get_upload_task_tagr'�submit�
PutObjectTaskrKr�r�)
rr�rIr;r�rFr�rZZput_object_extra_argsZput_object_tagrrrr�ls0	����	�
�z+UploadSubmissionTask._submit_upload_requestcCs6|jj}tD]*}||jkrd|jd<|�dd�|jd<q|�|j�}	|j�|t|j||j	|j
|	d�d��}
g}|�|j�}|�|d�}
|jj
}t�}|�|j|�}|�||�}|D]B\}}|�|jj|t|j|||j	|j
||d	�d
|
id�|
d��q�|�|j�}|j�|t|j||j	|j
|d�|
|d
�dd��dS)NZFULL_OBJECTr��Checksum�r�)r�r�r�r�)r)r��upload_part)r�r(r�r�rjr��	upload_id)r)r��pending_main_kwargsr�)r��partsT)r)r�r�r�)rYrZrr��replace�_extra_create_multipart_argsr'r�r	r�r��_extra_upload_part_argsr�r[rZadjust_chunksizeZmultipart_chunksizerM�append�UploadPartTask�_extra_complete_multipart_argsr)rr�rIr;r�rFr�rZZchecksumZcreate_multipart_extra_argsZcreate_multipart_futureZpart_futuresZextra_part_argsZupload_part_tagr[ZadjusterrLZ
part_iteratorrjr(Zcomplete_multipart_extra_argsrrrr��s�	

��������	���������z.UploadSubmissionTask._submit_multipart_requestcCst||j�Sr)r�UPLOAD_PART_ARGS�rr�rrrr��sz,UploadSubmissionTask._extra_upload_part_argscCst||j�Sr)r�COMPLETE_MULTIPART_ARGSr�rrrr��sz3UploadSubmissionTask._extra_complete_multipart_argscCst||jd�S�N)Zblocklisted_keys)r�CREATE_MULTIPART_BLOCKLISTr�rrrr��s�z1UploadSubmissionTask._extra_create_multipart_argscCst||jd�Sr�)r�PUT_OBJECT_BLOCKLISTr�rrrr�s�z+UploadSubmissionTask._extra_put_object_argscCsd}|�|�rt}|Sr)rDr)rr�rCr�rrrr�s
z)UploadSubmissionTask._get_upload_task_tag)N)r"r#r$r6r�rr�r�r�r�r�r�r�r�r�r�r�r�rrrrr�s<
�
��
�
9'cr�c@seZdZdZdd�ZdS)r�z Task to do a nonmultipart uploadc	Cs,|�}|jf|||d�|��W5QRXdS)aP
        :param client: The client to use when calling PutObject
        :param fileobj: The file to upload.
        :param bucket: The name of the bucket to upload to
        :param key: The name of the key to upload to
        :param extra_args: A dictionary of any extra arguments that may be
            used in the upload.
        )�Bucket�Key�BodyN)rs)rr�r(r�r�r�rrrr�_mains	zPutObjectTask._mainN�r"r#r$r6r�rrrrr�sr�c@seZdZdZdd�ZdS)r�z+Task to upload a part in a multipart uploadc	Cst|�"}|jf|||||d�|��}	W5QRX|	d}
|
|d�}d|krp|d��}d|��}
|
|	krp|	|
||
<|S)a�
        :param client: The client to use when calling PutObject
        :param fileobj: The file to upload.
        :param bucket: The name of the bucket to upload to
        :param key: The name of the key to upload to
        :param upload_id: The id of the upload
        :param part_number: The number representing the part of the multipart
            upload
        :param extra_args: A dictionary of any extra arguments that may be
            used in the upload.

        :rtype: dict
        :returns: A dictionary representing a part::

            {'Etag': etag_value, 'PartNumber': part_number}

            This value can be appended to a list to be used to complete
            the multipart upload.
        )r�r�ZUploadId�
PartNumberr��ETag)r�r�r�r�)r��upper)rr�r(r�r�r�rjr�r�response�etagZ
part_metadataZalgorithm_nameZchecksum_memberrrrr�"s$��

zUploadPartTask._mainNr�rrrrr�sr�)ro�iorZs3transfer.compatrrZs3transfer.constantsrZs3transfer.futuresrZs3transfer.tasksrr	r
rZs3transfer.utilsrr
rrrr%r7rVrrrwr�r�r�rrrr�<module>
s$!,{]1

F1le Man4ger