mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-03 14:27:32 +08:00
Port agent PRs to GO - 4 (#16652)
### Summary Port https://github.com/infiniflow/ragflow/pull/15399 https://github.com/infiniflow/ragflow/pull/16469
This commit is contained in:
@@ -307,14 +307,12 @@ func (h *DocumentHandler) GetDocumentPreview(c *gin.Context) {
|
||||
}
|
||||
|
||||
ext := utility.GetFileExtension(preview.FileName)
|
||||
if preview.ContentType != "" {
|
||||
c.Header("Content-Type", preview.ContentType)
|
||||
}
|
||||
|
||||
if utility.ShouldForceAttachment(ext, preview.ContentType) {
|
||||
c.Header("X-Content-Type-Options", "nosniff")
|
||||
c.Header("Content-Disposition", "attachment")
|
||||
}
|
||||
// Use the shared preview-headers helper so that safe types get
|
||||
// Content-Disposition: inline with filename, while dangerous
|
||||
// types (HTML, SVG, XML) fall back to forced attachment with
|
||||
// nosniff. Mirrors Python document_api.py:2063 which calls
|
||||
// apply_preview_file_response_headers() with the document name.
|
||||
utility.SetPreviewFileResponseHeaders(c.Writer.Header(), preview.ContentType, ext, preview.FileName)
|
||||
|
||||
c.Data(http.StatusOK, preview.ContentType, preview.Data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user