Is there any way to get the source files of documents already uploaded to the knowledge base? #21604

Closed
opened 2026-02-21 20:13:27 -05:00 by yindo · 2 comments
Owner

Originally created by @SchneeHertz on GitHub (Jan 13, 2026).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

I was using the /datasets/{dataset_id}/documents/{document_id}/upload-file endpoint in version 1.9 to get the source file of a document from the knowledge base, but in the latest version, this API has been removed. Is there an alternative way to get the source file of a document in the knowledge base?

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @SchneeHertz on GitHub (Jan 13, 2026). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. I was using the `/datasets/{dataset_id}/documents/{document_id}/upload-file` endpoint in version 1.9 to get the source file of a document from the knowledge base, but in the latest version, this API has been removed. Is there an alternative way to get the source file of a document in the knowledge base? ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [ ] I am interested in contributing to this feature.
yindo added the 🙋‍♂️ question label 2026-02-21 20:13:27 -05:00
yindo closed this issue 2026-02-21 20:13:27 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 13, 2026):

Hi @SchneeHertz! I'm Dosu and I’m helping the dify team.

The /datasets/{dataset_id}/documents/{document_id}/upload-file endpoint for downloading source files was removed in recent Dify versions for security reasons, and there is no direct replacement API in most releases reference. However, you still have a few options:

  • If you're self-hosting Dify, you can access the original files directly from your storage volume. The files are referenced in the upload_files table in your database, and the file path can be constructed using the key field. By matching the upload_file_id in a document's data_source_info, you can locate and extract the file from storage reference.

  • If you know the file ID, you can use the /files/<file_id>/file-preview endpoint to download the file. This requires generating a signed URL with the correct parameters (timestamp, nonce, HMAC signature) reference.

  • In the latest versions, a download button was reintroduced in the UI for knowledge base documents. This button calls a GET request to /datasets/{dataset_id}/documents/{document_id}/upload-file (if your version supports it), which returns a signed download URL for the source file reference.

If you need step-by-step help with extracting files from storage or the database, let me know your deployment details and I can guide you through the process.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 13, 2026): <!-- Greeting --> Hi @SchneeHertz! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> The `/datasets/{dataset_id}/documents/{document_id}/upload-file` endpoint for downloading source files was removed in recent Dify versions for security reasons, and there is no direct replacement API in most releases [reference](https://github.com/langgenius/dify/issues/27510). However, you still have a few options: - **If you're self-hosting Dify**, you can access the original files directly from your storage volume. The files are referenced in the `upload_files` table in your database, and the file path can be constructed using the `key` field. By matching the `upload_file_id` in a document's `data_source_info`, you can locate and extract the file from storage [reference](https://github.com/langgenius/dify/issues/30331). - **If you know the file ID**, you can use the `/files/<file_id>/file-preview` endpoint to download the file. This requires generating a signed URL with the correct parameters (timestamp, nonce, HMAC signature) [reference](https://github.com/langgenius/dify/blob/491e1fd6a4a1dba36459d92411120e5e2defb2a3/api/controllers/files/image_preview.py#L79-L149). - **In the latest versions**, a download button was reintroduced in the UI for knowledge base documents. This button calls a GET request to `/datasets/{dataset_id}/documents/{document_id}/upload-file` (if your version supports it), which returns a signed download URL for the source file [reference](https://github.com/langgenius/dify/pull/23320). If you need step-by-step help with extracting files from storage or the database, let me know your deployment details and I can guide you through the process. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/83f805b5-1a44-4d58-aa3b-0e0e2664e14a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/83f805b5-1a44-4d58-aa3b-0e0e2664e14a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/83f805b5-1a44-4d58-aa3b-0e0e2664e14a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/83f805b5-1a44-4d58-aa3b-0e0e2664e14a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/83f805b5-1a44-4d58-aa3b-0e0e2664e14a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/83f805b5-1a44-4d58-aa3b-0e0e2664e14a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/83f805b5-1a44-4d58-aa3b-0e0e2664e14a?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20%60/datasets/%7Bdataset_id%7D/documents/%7Bdocument_id%7D/upload-file%60%20endpoint%20for%20downloading%20source%20files%20was%20removed%20in%20recent%20Dify%20versions%20for%20security%20reasons%2C%20and%20there%20is%20no%20direct%20replacement%20API%20in%20most%20releases%C2%A0%5Breference%5D%28https%3A//github.com/langgenius/dify/issues/27510%29.%20However%2C%20you%20still%20have%20a%20few%20options%3A%0A%0A-%20%2A%2AIf%20you%27re%20self-hosting%20Dify%2A%2A%2C%20you%20can%20access%20the%20original%20files%20directly%20from%20your%20storage%20volume.%20The%20files%20are%20referenced%20in%20the%20%60upload_files%60%20table%20in%20your%20database%2C%20and%20the%20file%20path%20can%20be%20constructed%20using%20the%20%60key%60%20field.%20By%20matching%20the%20%60upload_file_id%60%20in%20a%20document%27s%20%60data_source_info%60%2C%20you%20can%20locate%20and%20extract%20the%20file%20from%20storage%C2%A0%5Breference%5D%28https%3A//github.com/langgenius/dify/issues/30331%29.%0A%0A-%20%2A%2AIf%20you%20know%20the%20file%20ID%2A%2A%2C%20you%20can%20use%20the%20%60/files/%3Cfile_id%3E/file-preview%60%20endpoint%20to%20download%20the%20file.%20This%20requires%20generating%20a%20signed%20URL%20with%20the%20correct%20parameters%20%28timestamp%2C%20nonce%2C%20HMAC%20signature%29%C2%A0%5Breference%5D%28https%3A//github.com/langgenius/dify/blob/491e1fd6a4a1dba36459d92411120e5e2defb2a3/api/controllers/files/image_preview.py%23L79-L149%29.%0A%0A-%20%2A%2AIn%20the%20latest%20versions%2A%2A%2C%20a%20download%20button%20was%20reintroduced%20in%20the%20UI%20for%20knowledge%20base%20documents.%20This%20button%20calls%20a%20GET%20request%20to%20%60/datasets/%7Bdataset_id%7D/documents/%7Bdocument_id%7D/upload-file%60%20%28if%20your%20version%20supports%20it%29%2C%20which%20returns%20a%20signed%20download%20URL%20for%20the%20source%20file%C2%A0%5Breference%5D%28https%3A//github.com/langgenius/dify/pull/23320%29.%0A%0AIf%20you%20need%20step-by-step%20help%20with%20extracting%20files%20from%20storage%20or%20the%20database%2C%20let%20me%20know%20your%20deployment%20details%20and%20I%20can%20guide%20you%20through%20the%20process.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/30904)
Author
Owner

@crazywoola commented on GitHub (Jan 13, 2026):

Nope

@crazywoola commented on GitHub (Jan 13, 2026): Nope
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21604