update bytesio to binaryio #2237
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request updates file handling in the
store_filemethod for both PostgreSQL and S3 providers to improve compatibility and correctness when working with binary file streams. The key changes include switching fromio.BytesIO/BytesIOto the more generalBinaryIOtype and updating file size calculation logic for PostgreSQL.Use BytesIO for small in-memory buffers; switch to file-based BinaryIO for large files.
Changes to file handling:
py/core/providers/file/postgres.py:file_contentparameter instore_fileand_write_lobjectmethods fromio.BytesIOtoBinaryIOfor broader compatibility with binary streams. [1] [2]store_fileto useseekandtellinstead ofgetbuffer().nbytes, ensuring compatibility with anyBinaryIOimplementation.py/core/providers/file/s3.py:file_contentparameter in thestore_filemethod fromBytesIOtoBinaryIOto align with the PostgreSQL provider and support a wider range of binary file streams.Important
Update
store_filemethods in PostgreSQL and S3 providers to useBinaryIOfor better binary stream compatibility.postgres.py: Changedfile_contenttype instore_fileand_write_lobjectfromio.BytesIOtoBinaryIO. Updated file size calculation instore_fileto useseekandtell.s3.py: Changedfile_contenttype instore_filefromBytesIOtoBinaryIO.This description was created by
for fbbc488. You can customize this summary. It will automatically update as commits are pushed.