In the documentation for put_object, Boto3 docs say that Body is simply:
Body (bytes) -- Object data.
and give the example:
Body=b'bytes',
Empirically, though, a Python file-like object works just fine. And the automated tests depend on this functionality, so it's probably not going away.
It would be nice if the documentation reflected that Body didn't have to be just bytes.
Good catch.
Documentation is mostly auto-generated from upstream. We will see what we can do here.
If you reached this page like me and found nothing on StackOverflow, you can use normal strings as the parameter to create text files. Here's a sample HTML one:
response = s3_client.put_object(
Bucket='your-s3-bucket-name',
Body='a big ole string, or html tags like <h1>Yooo</h1>',
Key='folder/path/index.html',
ServerSideEncryption='AES256'
)
Most helpful comment
If you reached this page like me and found nothing on StackOverflow, you can use normal strings as the parameter to create text files. Here's a sample HTML one: