Skip to content

Instantly share code, notes, and snippets.

@anna-geller
Created August 1, 2021 12:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anna-geller/16af585102078e42f5d55925f179d310 to your computer and use it in GitHub Desktop.
Save anna-geller/16af585102078e42f5d55925f179d310 to your computer and use it in GitHub Desktop.
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