-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsertTestS3.py
28 lines (21 loc) · 893 Bytes
/
insertTestS3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import boto3
# Set your AWS access keys as constants
AWS_ACCESS_KEY_ID = 'AKIA2SO5OU4DX7NOG2XX'
AWS_SECRET_ACCESS_KEY = 'SU7edBIdEBmrwYF/6fdwiMlwtKi/ZIJXWGV1QDFp'
# Create an S3 client using the access keys
s3 = boto3.client('s3',
aws_access_key_id=AWS_ACCESS_KEY_ID,
aws_secret_access_key=AWS_SECRET_ACCESS_KEY)
# Set the name of the bucket and the file you want to upload
bucket_name = 'area1alertsbucket'
file_name = 'data.txt'
# Set the string you want to upload
test_string = 'test ABC'
# Use the S3 client to upload the string to the bucket
try:
# Use the S3 client to upload the string to the bucket
s3.put_object(Bucket=bucket_name, Key=file_name, Body=test_string)
print("String uploaded successfully to S3 bucket")
except Exception as e:
# Print any errors that occurred
print("Error uploading string to S3 bucket:", e)