Created
August 1, 2021 12:03
-
-
Save anna-geller/16af585102078e42f5d55925f179d310 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
bucket_name = "annageller" | |
s3_object = "ted_lasso.txt" | |
s3_object_body = "Be curious, not judgemental" | |
s3_resource = boto3.resource("s3") | |
upload_result = s3_resource.Object(bucket_name, s3_object).put(Body=s3_object_body) | |
assert upload_result["ResponseMetadata"]["HTTPStatusCode"] == 200 | |
text_file_from_s3 = ( | |
s3_resource.Object(bucket_name, s3_object).get()["Body"].read().decode("utf-8") | |
) | |
assert s3_object_body == text_file_from_s3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment