oTree Forum >

Upload single file on Internal Assets for OTAI project

#1 by AndreL

I am trying to upload an individual file to the OTAI internal asset folder, but cannot manage to do it. Am I missing something extremely obvious?

I only see the option to upload a whole folder, which then generates a crashing error when launching a demo session.

#2 by Chris_oTree

Hi, you can only upload a folder, not individual files. If you want to upload individual files you would need to first put them in a folder on your PC. 

What is the crashing error you get?

#3 by AndreL

Using the folder structure automatically loads the file within a folder, which is then not found when a demo session starts (using OTAI).

Traceback (most recent call last):
  File "otree/errorpage.py", line 276, in otree.errorpage.OTreeServerErrorMiddleware.__call__
  File "/opt/otree-envs/otree-6.1.22/lib/python3.14/site-packages/starlette/middleware/base.py", line 25, in __call__
    response = await self.dispatch_func(request, self.call_next)
  File "otree/middleware.py", line 28, in dispatch
  File "/opt/otree-envs/otree-6.1.22/lib/python3.14/site-packages/starlette/middleware/base.py", line 45, in call_next
    task.result()
  File "/opt/otree-envs/otree-6.1.22/lib/python3.14/site-packages/starlette/middleware/base.py", line 38, in coro
    await self.app(scope, receive, send)
  File "/opt/otree-envs/otree-6.1.22/lib/python3.14/site-packages/starlette/middleware/sessions.py", line 75, in __call__
    await self.app(scope, receive, send_wrapper)
  File "otree/patch.py", line 44, in __call__
  File "otree/patch.py", line 32, in otree.patch.ExceptionMiddleware.__call__
  File "/opt/otree-envs/otree-6.1.22/lib/python3.14/site-packages/starlette/routing.py", line 582, in __call__
    await route.handle(scope, receive, send)
  File "/opt/otree-envs/otree-6.1.22/lib/python3.14/site-packages/starlette/routing.py", line 243, in handle
    await self.app(scope, receive, send)
  File "otree/views/abstract/base.py", line 134, in dispatch
  File "/opt/otree-envs/otree-6.1.22/lib/python3.14/site-packages/starlette/concurrency.py", line 40, in run_in_threadpool
    return await loop.run_in_executor(None, func, *args)
  File "/home/ubuntu/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/thread.py", line 86, in run
    result = ctx.run(self.task)
  File "/home/ubuntu/.pyenv/versions/3.14.3/lib/python3.14/concurrent/futures/thread.py", line 73, in run
    return fn(*args, **kwargs)
  File "otree/views/abstract/base.py", line 149, in otree.views.abstract.base.FormPageOrInGameWaitPage._dispatch_sync
  File "otree/views/abstract/base.py", line 150, in otree.views.abstract.base.FormPageOrInGameWaitPage._dispatch_sync
  File "otree/database.py", line 189, in otree.database.run_request_in_scope
  File "otree/database.py", line 184, in otree.database.run_request_in_scope
  File "otree/views/abstract/base.py", line 182, in otree.views.abstract.base.FormPageOrInGameWaitPage._dispatch_sync_gated
  File "otree/views/abstract/base.py", line 194, in otree.views.abstract.base.FormPageOrInGameWaitPage._dispatch_sync_gated
  File "otree/views/abstract/base.py", line 184, in otree.views.abstract.base.FormPageOrInGameWaitPage._dispatch_sync_gated
  File "otree/views/abstract/page.py", line 84, in otree.views.abstract.page.Page.inner_dispatch
  File "otree/views/abstract/page.py", line 441, in otree.views.abstract.page.Page.post
  File "otree/views/abstract/base.py", line 97, in otree.views.abstract.base.FormPageOrInGameWaitPage.call_user_defined
  File "/srv/otree-sites/newtown/code/home_entry/__init__.py", line 73, in error_message
    return check_in_problem(player)
  File "/srv/otree-sites/newtown/code/home_entry/__init__.py", line 35, in check_in_problem
    codes = student_codes()
  File "/srv/otree-sites/newtown/code/home_entry/__init__.py", line 52, in student_codes
    text = ot.read_file(C.STUDENT_CODES_FILE, fixture='student_codes')
  File "otree/effects.py", line 363, in otree.effects._Ot.read_file
FileNotFoundError: [Errno 2] No such file or directory: 'otree_input/student_codes.csv'

#4 by AndreL

It seems OTAI was building relative file paths wrong but it fixed itself (it took several repeats of the error and dead-end suggestions before it did it and now the demo works.

_______________________ OATI agent:
Fixed. The problem was that the file path was being resolved relative to the server's internal working folder, not your uploaded files folder, so the file was never found.

The check-in now builds the full path from the uploaded-files folder itself, so the file stays exactly where you have it (otree_input/students_codes.csv).

I verified this by temporarily making the tests read your real uploaded file instead of the built-in dummy list: it loaded and parsed correctly, your student 12345678 / code ABC123 matched, and the tests passed with 100% coverage. The tests are now back to using their own built-in dummy list, so they stay fast and don't depend on your real codes.
9/14/2026, 9:20:06 PM

#5 by Chris_oTree

Hi, thank you for reporting! I've made a fix so that this shouldn't happen again.

Write a reply

Set forum username