[PYTHON] Download the file from S3 using boto.

Convenient to get a connection from boto.connect_s3, a bucket from there, and even a key.

version

code

from cStringIO import StringI

from boto import connect_s3

# token
access_key = ''
secret_key = ''

# bucket, key
bucket_name = ''
file_key = ''

#Get files from S3
conn = connect_s3(access_key, secret_key)
bucket = conn.get_bucket(bucket_name)
key = bucket.get_key(file_key)

# key_Returns None if could not be retrieved by name
if not key:
    return u'No'

#File download and write to StgingIO
fp = StringIO()
key.get_contents_to_file(fp)
fp.seek(0)

Recommended Posts

Download the file from S3 using boto.
Download the image from the text file containing the URL
Analyze S3 CloudTrail Log using Boto
Download images from "Irasutoya" using Scrapy
Download the file deployed with appcfg.py
Extract the targz file using python
Get the file path using Pathlib
Download XBRL file from EDINET (personal memo)
Use boto to upload / download files to s3.
Download the file with PHP [Under construction]
Create wav file from GLSL shader using python3
[Python] Summary of S3 file operations with boto3
Operate the schedule app using python from iphone
Run a Python file from html using Django
Using the 3D plot library MayaVi from Julia
Download the csv file created by Google Colaboratory
I want to see the file name from DataLoader
Download the file while viewing the progress in Python 3.x
Get the file name in a folder using glob
File renaming using the full path received by the shell
DJango Note: From the beginning (using a generic view)
Issue S3 time-limited URL with boto3 (with file existence confirmation)
Copy S3 files from Python to GCS using GSUtil
Study from the beginning of Python Hour8: Using packages
I tried reading data from a file using Node.js.
A little bit from Python using the Jenkins API
Download images using requests
Extract data from S3
Access Google Cloud Storage from Python (boto) using your service account and key file (p12)
S3 uploader with boto
File encryption using OpenSSL
Control smart light "Yeelight" from Python without using the cloud
Use Boto3 to retrieve over 1000 Prefixes from S3's file list
Recursively copy files from the directory directly under the directory using Python
Access the file with a relative path from the execution script.
Get the file name saved in AWS S3 (1000 or more)
Paste the image into an excel file using Python's openpyxl
Download the top 10 views from one Youtube channel at once
The story of copying data from S3 to Google's TeamDrive
Convert pixiv to mp4 and download from pixiv using python's pixivpy
Play music from USB speakers using the ROS package (gx_sound_player)