fix: preserve correct Content-Type for inline file preview#37545
Open
ifer47 wants to merge 1 commit into
Open
Conversation
The /file-preview endpoint unconditionally set Content-Type to application/octet-stream, overriding the correct MIME type from upload_file.mime_type even when as_attachment=False (inline preview). Now the override only applies when downloading as an attachment, matching the pattern already used in the service API endpoint. Closes langgenius#37198 Co-Authored-By: zhipu/glm-5 <zai-org@claude-code-best.win>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/file-previewendpoint unconditionally setsContent-Type: application/octet-stream, overriding the correct MIME type (upload_file.mime_type) even for inline previews whereas_attachment=FalseContent-Typeoverride inside theif args.as_attachment:block so it only applies for downloads, matching the pattern already used in the service API endpoint (controllers/service_api/app/file_preview.py)Test plan
as_attachment) returns the correctContent-Typematching the file's MIME typeas_attachment=True) still returnsContent-Type: application/octet-streamenforce_download_for_htmlstill forcesapplication/octet-streamfor HTML content (security measure preserved)Closes #37198
🤖 Generated with Claude Code Best