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 download files on mongoengine #228

Closed
eneakllomollari opened this issue Jul 7, 2023 · 2 comments
Closed

Bug: Unable to download files on mongoengine #228

eneakllomollari opened this issue Jul 7, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@eneakllomollari
Copy link

Describe the bug
When uploading files or images using mongoengine, it's unable to view due to the incorrect type being passed to StreamingResponse

To Reproduce

  • Create an object with a FileField/ImageField
  • Attempt to view the file you just uploaded. The thumbnail and download functionality don't work

Environment (please complete the following information):

  • starlette-admin==0.10.0
  • mongoengine==0.27.0
  • Python 3.7.16

Additional context

Traceback (most recent call last):
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 405, in run_asgi
    self.scope, self.receive, self.send
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/fastapi/applications.py", line 270, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/middleware/exceptions.py", line 75, in __call__
    raise exc
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/middleware/exceptions.py", line 64, in __call__
    await self.app(scope, receive, sender)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/routing.py", line 680, in __call__
    await route.handle(scope, receive, send)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/routing.py", line 427, in handle
    await self.app(scope, receive, send)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/middleware/exceptions.py", line 75, in __call__
    raise exc
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/middleware/exceptions.py", line 64, in __call__
    await self.app(scope, receive, sender)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/routing.py", line 680, in __call__
    await route.handle(scope, receive, send)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/routing.py", line 275, in handle
    await self.app(scope, receive, send)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/routing.py", line 68, in app
    await response(scope, receive, send)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/responses.py", line 273, in __call__
    await wrap(partial(self.listen_for_disconnect, receive))
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 662, in __aexit__
    raise exceptions[0]
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 702, in _run_wrapped_task
    await coro
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/responses.py", line 269, in wrap
    await func()
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/responses.py", line 258, in stream_response
    async for chunk in self.body_iterator:
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/concurrency.py", line 63, in iterate_in_threadpool
    yield await anyio.to_thread.run_sync(_next, iterator)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/anyio/to_thread.py", line 32, in run_sync
    func, *args, cancellable=cancellable, limiter=limiter
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/Users/enea/lean_mail/backend/venv/lib/python3.7/site-packages/starlette/concurrency.py", line 53, in _next
    return next(iterator)
TypeError: 'GridOut' object is not an iterator
@eneakllomollari eneakllomollari added the bug Something isn't working label Jul 7, 2023
eneakllomollari added a commit to eneakllomollari/starlette-admin that referenced this issue Jul 7, 2023
@jowilf
Copy link
Owner

jowilf commented Jul 7, 2023

I'm unable to reproduce your issue, It may be linked to the Starlette/FastAPi version you're using. Can you try with the latest version of starlette ?

@eneakllomollari
Copy link
Author

Tried with starlette==0.20.4 and seems to be fixed. Thank you!

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

2 participants