-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation of put_object is confusing #4126
Comments
Thanks for highlighting this issue, since the example is in botocore I went ahead and created a PR there (boto/botocore#3177) to address this. It looks like just removing the |
I do not believe this is enough. This is another example: response = client.put_object(
Body='HappyFace.jpg',
Bucket='examplebucket',
Key='HappyFace.jpg',
)
print(response) It is also confusing since the code does not upload a file from local disk; instead it created a file in S3 with the text "HappyFace.jpg" as content. |
Ok although the PR addresses the inconsistency in that example, the issue remains where the examples may be misleading. Probably something like this is better: import boto3
client = boto3.client('s3')
with open('HappyFace.jpg', 'rb') as file:
response = client.put_object(
Body=file.read(),
Bucket='examplebucket',
Key='HappyFace.jpg',
)
print(response) |
Describe the issue
See here: https://github.com/boto/botocore/blob/8b29f58b6f09935e5ec83f4adade36e81643d32f/botocore/data/s3/2006-03-01/examples-1.json#L1645
This renders:
The description is "The following example uploads an object. The request specifies optional object tags. The bucket is versioned, therefore S3 returns version ID of the newly created object." However, the code does not update a file to S3. Instead, it create a file HappyFace.jpg with content is literally "c:\HappyFace.jpg".
Compare https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html where a Python file object is created before passed to boto3.
Links
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3/client/put_object.html
The text was updated successfully, but these errors were encountered: