Skip to content

Unable to determine the file's size. #158

@logicli0n

Description

@logicli0n

from sqlalchemy_file import FileField
class A(Base):
file: Mapped[dict] = mapped_column(FileField, nullable=True)
files = relationship(
"B", back_populates="homework", passive_deletes=True,
lazy="joined"
)

class B(Base):
a_id:Mapped[int]
file: Mapped[dict] = mapped_column(FileField, nullable=True)
a = relationship("A", back_populates="files")

fields = [
IntegerField(name="id", read_only=True),
HasOne("document", identity="document", required=True),
StringField("title"),
TextAreaField("description"),
TextAreaField("requirement"),
FileField(name="file"),
ListField(
field=CollectionField(
"files",
fields=[
IntegerField(name="id", read_only=True),
FileField(name="file"),
]
)
)
]

Когда добавляю файл внутри ListField дает ошибку Unable to determine the file's size.

File "/usr/local/lib/python3.12/site-packages/sqlalchemy_file/file.py", line 66, in init
size = get_content_size_from_fileobj(self.original_content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/sqlalchemy_file/helpers.py", line 63, in get_content_size_from_fileobj
raise RuntimeError("Unable to determine the file's size.") # pragma: no cover
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Unable to determine the file's size.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions