Skip to content

Project files: Add upload helpers#306

Merged
iLLiCiTiT merged 15 commits intodevelopfrom
enhancement/project-files-upload-helpers
Mar 3, 2026
Merged

Project files: Add upload helpers#306
iLLiCiTiT merged 15 commits intodevelopfrom
enhancement/project-files-upload-helpers

Conversation

@iLLiCiTiT
Copy link
Member

@iLLiCiTiT iLLiCiTiT commented Feb 25, 2026

Changelog Description

Add helper methods for project file upload.

Additional information

Noticed we have download but not upload. Idea came from community question asking why upload_file does not work, and it is because the endpoint expects to use POST method instead of PUT.

Testing notes:

  1. Project file can be easily uploaded.

@iLLiCiTiT iLLiCiTiT added the type: enhancement New feature or request label Feb 25, 2026
@iLLiCiTiT iLLiCiTiT self-assigned this Feb 25, 2026
Copy link
Contributor

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import ayon_api

filepath = r"C:\Users\User\Downloads\amazing.json"
print(ayon_api.upload_project_file("test", filepath=filepath))

Gives:

Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\JetBrains\PyCharm2025.3\scratches\ayon_api_upload_project_file.py", line 6, in <module>
    print(ayon_api.upload_project_file("test", filepath=filepath))
  File "C:\roydev\dev\ayon-python-api\ayon_api\_api.py", line 1022, in upload_project_file
    return con.upload_project_file(
  File "C:\roydev\dev\ayon-python-api\ayon_api\server_api.py", line 1546, in upload_project_file
    return self.upload_file(
  File "C:\roydev\dev\ayon-python-api\ayon_api\server_api.py", line 1862, in upload_file
    return self.upload_file_from_stream(
  File "C:\roydev\dev\ayon-python-api\ayon_api\server_api.py", line 1813, in upload_file_from_stream
    return self._upload_file(
  File "C:\roydev\dev\ayon-python-api\ayon_api\server_api.py", line 1769, in _upload_file
    response.raise_for_status()
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://127.0.0.1:5000/api/projects/test/files

Server creates logs:

2026-02-26 21:40:29 ERROR   api.server                 | Request validation error in [POST] /api/projects/test/files
2026-02-26 21:40:29     traceback:
2026-02-26 21:40:29       x-file-name: field required

Hence the lack of the x-file-name header is the issue?

@iLLiCiTiT iLLiCiTiT requested a review from BigRoy March 2, 2026 16:27
Copy link
Contributor

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appears to be working now.

Upload works, download works, delete works.

@iLLiCiTiT iLLiCiTiT merged commit c06ebfe into develop Mar 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants