Skip to content
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

Bug: Unable to determine the file's size. #589

Open
logicli0n opened this issue Oct 11, 2024 · 0 comments
Open

Bug: Unable to determine the file's size. #589

logicli0n opened this issue Oct 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@logicli0n
Copy link

logicli0n commented Oct 11, 2024

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"),
]
)
)
]

When I add FileField in CollectionField I get error ---> 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.

@logicli0n logicli0n added the bug Something isn't working label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant