Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
60e5adc7
Commit
60e5adc7
authored
Jun 22, 2024
by
Timothy J. Baek
Browse files
enh: files api allow filename
parent
de367e48
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
backend/apps/webui/routers/files.py
backend/apps/webui/routers/files.py
+23
-0
No files found.
backend/apps/webui/routers/files.py
View file @
60e5adc7
...
@@ -194,6 +194,29 @@ async def get_file_content_by_id(id: str, user=Depends(get_verified_user)):
...
@@ -194,6 +194,29 @@ async def get_file_content_by_id(id: str, user=Depends(get_verified_user)):
)
)
@
router
.
get
(
"/{id}/content/{file_name}"
,
response_model
=
Optional
[
FileModel
])
async
def
get_file_content_by_id
(
id
:
str
,
user
=
Depends
(
get_verified_user
)):
file
=
Files
.
get_file_by_id
(
id
)
if
file
:
file_path
=
Path
(
file
.
meta
[
"path"
])
# Check if the file already exists in the cache
if
file_path
.
is_file
():
print
(
f
"file_path:
{
file_path
}
"
)
return
FileResponse
(
file_path
)
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_404_NOT_FOUND
,
detail
=
ERROR_MESSAGES
.
NOT_FOUND
,
)
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_404_NOT_FOUND
,
detail
=
ERROR_MESSAGES
.
NOT_FOUND
,
)
############################
############################
# Delete File By Id
# Delete File By Id
############################
############################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment