Skip to content

Commit

Permalink
feat(file_manager): add support for file extension attribute
Browse files Browse the repository at this point in the history
- Introduced `EXTENSION` to `FileAttribute` enum.
- Updated `get_attr` function to handle the new `EXTENSION` attribute.
  • Loading branch information
laipz8200 committed Sep 28, 2024
1 parent 318080c commit e269550
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/core/file/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class FileAttribute(str, Enum):
MIME_TYPE = "mime_type"
TRANSFER_METHOD = "transfer_method"
URL = "url"
EXTENSION = "extension"


class ArrayFileAttribute(str, Enum):
Expand Down
2 changes: 2 additions & 0 deletions api/core/file/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def get_attr(*, file: "File", attr: "FileAttribute"):
return file.transfer_method.value
case FileAttribute.URL:
return file.remote_url
case FileAttribute.EXTENSION:
return file.extension
case _:
raise ValueError(f"Invalid file attribute: {attr}")

Expand Down

0 comments on commit e269550

Please sign in to comment.