LoginSignup
0
1

More than 5 years have passed since last update.

AWS S3 sample python project

Last updated at Posted at 2018-08-14

Sample adding image in AWS S3 with python

we will use Boto3 which is the Amazon Web Services (AWS) SDK for Python which allows Python developers to write software that makes use of Amazon services like S3 and EC2. Boto provides an easy to use, object-oriented API as well as low-level direct service access.

Installation
pip install boto3

SAMPLE CODE

import boto3
from botocore.client import Config

ACCESS_KEY_ID = 'your_key_id'
ACCESS_SECRET_KEY = 'your_secret_key'
BUCKET_NAME = 'your_bucket_name'

data = open('test.png', 'rb')

s3 = boto3.resource(
    's3',
    aws_access_key_id=ACCESS_KEY_ID,
    aws_secret_access_key=ACCESS_SECRET_KEY,
    config=Config(signature_version='s3v4')
)

s3.Bucket(BUCKET_NAME).put_object(Key='test.png', Body=data)

print ("Done")
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1