Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
8 changes: 5 additions & 3 deletions py/core/providers/file/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ async def store_file(
self,
document_id: UUID,
file_name: str,
file_content: io.BytesIO,
file_content: BinaryIO,
file_type: Optional[str] = None,
) -> None:
"""Store a new file in the database."""
size = file_content.getbuffer().nbytes
file_content.seek(0, 2)
size = file_content.tell()
file_content.seek(0)

async with (
self.connection_manager.pool.get_connection() as conn # type: ignore
Expand All @@ -108,7 +110,7 @@ async def store_file(
)

async def _write_lobject(
self, conn, oid: int, file_content: io.BytesIO
self, conn, oid: int, file_content: BinaryIO
) -> None:
"""Write content to a large object."""
lobject = await conn.fetchval("SELECT lo_open($1, $2)", oid, 0x20000)
Expand Down
2 changes: 1 addition & 1 deletion py/core/providers/file/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def store_file(
self,
document_id: UUID,
file_name: str,
file_content: BytesIO,
file_content: BinaryIO,
file_type: Optional[str] = None,
) -> None:
"""Store a file in S3."""
Expand Down
Loading