S3 (Boto3) - sjherrick/code-base GitHub Wiki

S3 (Boto3)

Read Object from S3

  • Example (Excel file)
s3 = boto3.client('s3', region_name='us-east-1')
obj = s3.get_object(Bucket=<BUCKET-NAME>, Key=<FILE-NAME>)
data = obj['Body'].read()
book = xlrd.open_workbook(file_contents=data)
sheet = book.sheet_by_name('Sheet1')

Upload File to S3

response = s3.upload_file(TEXTBASE_PATH, BUCKET, KEY)

⚠️ **GitHub.com Fallback** ⚠️