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/boto/file/__pycache__/ |
Upload File : |
o ckF[� � @ s8 d dl Z d dlZd dlZd dlmZ G dd� de�ZdS )� N)�StringIOc @ s| e Zd ZdZdZeeB ZdZdefdd�Zdd� Zddd�Z ddd�Z ddd�Z ddd�Zdd� Z dd� ZdS )�Key� � r Nc C s~ || _ || _|dkrd | _d | _n || _t�|�j| _|| _|| jkr,t j | _d| _d S || jkr:t j | _d| _d S || _d S )N�-z<STDIN>z<STDOUT>)�bucket� full_path�name�size�os�stat�st_size�key_type�KEY_STREAM_READABLE�sys�stdin�fp�KEY_STREAM_WRITABLE�stdout)�selfr r r r � r �//usr/lib/python3/dist-packages/boto/file/key.py�__init__% s zKey.__init__c C s d| j S )Nzfile://)r �r r r r �__str__8 s zKey.__str__� Fc C sZ | j | j@ r td��| j | j@ r| j}nt| jd�}z t�||� W |� � dS |� � w )aT Retrieves a file from a Key :type fp: file :param fp: File pointer to put the data into :type headers: string :param: ignored in this subclass. :type cb: function :param cb: ignored in this subclass. :type cb: int :param num_cb: ignored in this subclass. zStream is not readable�rbN) r r �BotoClientErrorr r �openr �shutil�copyfileobj�close)r r �headers�cb�num_cb�torrent�key_filer r r �get_file; s zKey.get_fileTc C sp | j | j@ r td��| j | j@ r| j}n|stj�| j�rdS t | jd�}z t �||� W |�� dS |�� w )a Store an object in a file using the name of the Key object as the key in file URI and the contents of the file pointed to by 'fp' as the contents. :type fp: file :param fp: the file whose contents to upload :type headers: dict :param headers: ignored in this subclass. :type replace: bool :param replace: If this parameter is False, the method will first check to see if an object exists in the bucket with the same key. If it does, it won't overwrite it. The default value is True which will overwrite the object. :type cb: function :param cb: ignored in this subclass. :type cb: int :param num_cb: ignored in this subclass. :type policy: :class:`boto.s3.acl.CannedACLStrings` :param policy: ignored in this subclass. :type md5: A tuple containing the hexdigest version of the MD5 checksum of the file as the first element and the Base64-encoded version of the plain checksum as the second element. This is the same format returned by the compute_md5 method. :param md5: ignored in this subclass. zStream is not writableN�wb) r r r r r r �path�existsr r r r r! ) r r r"