feat: add GET upload file API endpoint to dataset service api
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:
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:
Doc preview:
Checklist
- [ ] This change requires a documentation update, included: Dify Document
- [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) andcd web && npx lint-staged(frontend) to appease the lint gods
@laipz8200 Hi, could you please take a look the PR, and let me know if you have any feedback? Thank you.