<jupyter_start><jupyter_text>*  Install boto3 python module* __using jupyter and pip:__ * import sys* !{sys.executable} -m pip install boto3* __or runing python by terminal:__* pip install boto3 *  Uploading files<jupyter_code>import logging
import boto3
from botocore.exceptions import ClientError

def upload_file(file_name, bucket="tekmore", object_name=None):
    if object_name is None:
        object_name = file_name
    s3_client = boto3.client('s3')
    try:
        response = s3_client.upload_file(file_name, bucket, object_name)
    except ClientError as e:
        logging.error(e)
        return("Houve um erro no envio do arquivo!")
    return("Arquivo enviado com sucesso!")
upload_file("pythons2.jpeg")<jupyter_output><empty_output><jupyter_text>*  Listing the content files<jupyter_code>from boto3 import client

connection = client('s3')
for key in connection.list_objects(Bucket='tekmore')['Contents']:
    print(key['Key'])<jupyter_output>SeminarioBioquimicaFinal.pptx
pythons2.jpeg<jupyter_text>*  Downloading files<jupyter_code>from boto3 import client

s3 = boto3.client('s3')
s3.download_file('tekmore', 'pythons2.jpeg', 'downloadedpythons2.jpeg')
def download_file(file_name, bucket='tekmore', new_name='downloaded file'):
    s3 = boto3.client('s3')
    s3.download_file(bucket, file_name, new_name)
download_file('pythons2.jpeg', 'tekmore', 'meu_novo_arquivo')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11283497884344147, 'fraction_numerical': 0.01692524682651622, 'mean_word_length': 6.059701492537314, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '594448', 'license': 'MIT', 'n_tokens_mistral': 520, 'n_tokens_neox': 512, 'n_words': 105, 'path': 's3upload.ipynb', 'repo_name': 'victor-s-santos/python-s3-imagem-upload-download', 'size': '1418'}