Use boto to upload / download files to s3.

Version:

When using Python, please try using virtualenv. Managing the library will be much easier.

code

from boto.s3.key import Key
from boto.s3.connection import S3Connection

#access code
AWS_SECRET_ACCESS_KEY = ''
AWS_ACCESS_KEY_ID = ''

bucket_name = ''
key_name = ''


conn = S3Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
bucket = conn.create_bucket(bucket_name)

k = Key(bucket)

#Upload
#file_name is upro-The name of the file in the directory you want to
k.key = key_name
k.set_contents_from_filename(file_name)


#Download
k.get_contents_to_filename(file_name)

Recommended Posts

Use boto to upload / download files to s3.
Use boto3 to mess with S3
Let's upload S3 files with CLI
A script that uses boto to upload a specified folder to Amason S3
Download the file from S3 using boto.
How to catch boto3 S3 NoSuchKey error
Don't use rm command to delete files
How to automatically upload .gpx files to Strava
Why you should use urlopen instead of urlretrieve to download Python files
Upload scraped artifacts in Scrapy Cloud to S3
Use the retry processing mode added to Boto3
Use boto3-stubs to enable code completion on boto3
Download files directly to Google Drive (using Google Colaboratory)
Upload files to Google Drive with Lambda (Python)
Upload images to S3 with GUI using tkinter
Resize multipart.File type image with golang ~ Upload to S3
Upload the image downloaded by requests directly to S3
Copy files directly from Amazon EC2 (Amazon linux) to S3
How to use variables in systemd Unit definition files
How to download files from Selenium in Python in Chrome
How to upload files in Django generic class view
Copy S3 files from Python to GCS using GSUtil
How to use xml.etree.ElementTree
Upload files with Django
How to use Python-shell
How to use tf.data
How to use virtualenv
How to use Seaboan
How to use image-match
How to use Pandas 2
How to use Virtualenv
How to use pytest_report_header
How to use Bio.Phylo
How to use SymPy
How to use x-means
How to use WikiExtractor.py
How to use IPython
How to use virtualenv
How to use Matplotlib
How to use iptables
How to use numpy
Reasons to use logarithm
How to use TokyoTechFes2015
How to use venv
How to use dictionary {}
How to use Pyenv
S3 uploader with boto
Easy to use SQLite3
How to use python-kabusapi
Python-How to use pyinstaller
How to use return
How to use dotenv
How to use pyenv-virtualenv
How to use Go.mod
How to use imutils
How to use import
Use Boto3 to retrieve over 1000 Prefixes from S3's file list
How to upload files to Cloud Storage with Firebase's python SDK
I wanted to delete multiple objects in s3 with boto3
Upload and delete files to Google Cloud Storages with django-storage