1. uasi

    use codeblock

    uasi
Changes in body
Source | HTML | Preview
@@ -1,26 +1,29 @@
#**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'
+```python
+import boto3
+from botocore.client import Config
+
+ACCESS_KEY_ID = 'your_key_id'
ACCESS_SECRET_KEY = 'your_secret_key'
-BUCKET_NAME = 'your_bucket_name'`
+BUCKET_NAME = 'your_bucket_name'
-`data = open('test.png', 'rb')`
+data = open('test.png', 'rb')
-`s3 = boto3.resource(
+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)`
+s3.Bucket(BUCKET_NAME).put_object(Key='test.png', Body=data)
-`print ("Done")`
+print ("Done")
+```