You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When passing a file to boto3.client("s3").upload_fileobj the file gets closed silently. This causes, bugs (or requires reopening the file), to continue working on it.
Expected Behavior
File remains open after passing it to upload_fileobj.
Current Behavior
File gets closed and any further operation on the file produces and exception: ValueError: I/O operation on closed file.
Reproduction Steps
To produce the exception because of upload_fileobj silently closing the file:
fromioimportBytesIOimportboto3client=boto3.client("s3")
text="Some text to upload"withBytesIO(text.encode("utf-8")) asf:
client.upload_fileobj(f, "bucket", "path/filename.txt")
f.seek(0, 2) # or any other operation
If we swap the the operations around the exception goes away:
fromioimportBytesIOimportboto3client=boto3.client("s3")
text="Some text to upload"withBytesIO(text.encode("utf-8")) asf:
f.seek(0, 2) # or any other operationclient.upload_fileobj(f, "bucket", "path/filename.txt")
Possible Solution
No response
Additional Information/Context
No response
SDK version used
1.28.38
Environment details (OS name and version, etc.)
NixOS 23.05
The text was updated successfully, but these errors were encountered:
Hi @Foxicution thanks for reaching out. We have received a few issues in the past related to this. It looks like the most recent one was mistakenly auto-closed: #3150. I just reopened it for tracking. The last comment I made there is still relevant:
...I brought this up for discussion with the team and they agreed that a short reference to this behavior could be added to the documentation if you want to create a PR. There is still some debate over whether the s3transfer issue should be considered a bug. But someone did share a workaround here in the comments.
I'll try raising this issue again with the team because I do see a lot of frustration in that related s3transfer issue (boto/s3transfer#80). But I'm going to close this as a duplicate and we can continue tracking the linked issues.
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe the bug
When passing a file to
boto3.client("s3").upload_fileobj
the file gets closed silently. This causes, bugs (or requires reopening the file), to continue working on it.Expected Behavior
File remains open after passing it to
upload_fileobj
.Current Behavior
File gets closed and any further operation on the file produces and exception:
ValueError: I/O operation on closed file.
Reproduction Steps
To produce the exception because of upload_fileobj silently closing the file:
If we swap the the operations around the exception goes away:
Possible Solution
No response
Additional Information/Context
No response
SDK version used
1.28.38
Environment details (OS name and version, etc.)
NixOS 23.05
The text was updated successfully, but these errors were encountered: