[PR #11899] feat: add GET upload file API endpoint to dataset service api #27397

Closed
opened 2026-02-21 20:41:26 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/11899

State: closed
Merged: Yes


Summary

It's related to issues #9547 and #10296

When an app references a Knowledge resource, we want to download the source files linked in the citations section of the resulting chat message:

image

I known Dify team has permission concerns, and this is not a high priority from #9547.

So to keep it simple, this PR adds an API to retrieve upload file infos ( including download URL) from related documents.

The chat-messages API already provides document infos within the metadata - retriever_resources field.

In addition to this PR, we can achieve source file downloads within our custom chat app.

This API also supports broader use cases related to uploaded files, such as downloading individual files or even batch downloading files from a knowledge base.

So this PR could be beneficial to other users.

For code style and consistency, I referenced existing code snippets:

`api/controllers/service_api/dataset/segment.py:72` # Fetch document
`api/controllers/console/datasets/datasets_document.py:373` # Fetch upload_file
`api/controllers/console/remote_files.py:72` # Return fields

Screenshots

Local API test result:

image

Doc preview:

image

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/11899 **State:** closed **Merged:** Yes --- # Summary It's related to issues #9547 and #10296 When an app references a Knowledge resource, we want to download the source files linked in the citations section of the resulting chat message: <img width="598" alt="image" src="https://github.com/user-attachments/assets/a1305ac9-6473-44d8-b751-c8a9d9e2b12b" /> I known Dify team has permission concerns, and this is not a high priority from #9547. So to keep it simple, this PR adds an API to retrieve upload file infos ( including download URL) from related documents. The chat-messages API already provides document infos within the `metadata - retriever_resources` field. In addition to this PR, we can achieve source file downloads within our custom chat app. This API also supports broader use cases related to uploaded files, such as downloading individual files or even batch downloading files from a knowledge base. So this PR could be beneficial to other users. For code style and consistency, I referenced existing code snippets: ```py `api/controllers/service_api/dataset/segment.py:72` # Fetch document `api/controllers/console/datasets/datasets_document.py:373` # Fetch upload_file `api/controllers/console/remote_files.py:72` # Return fields ``` # Screenshots Local API test result: <img width="1298" alt="image" src="https://github.com/user-attachments/assets/6beef869-f488-4fb6-a7fa-c8e248fb670d" /> Doc preview: <img width="1373" alt="image" src="https://github.com/user-attachments/assets/513f7321-d93d-43ad-8f05-713a8bdb8610" /> # Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:41:26 -05:00
yindo closed this issue 2026-02-21 20:41:26 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#27397