Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for specifying content-type with OSS across storage… #17166

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

IthacaDream
Copy link
Contributor

Summary

feat: add support for specifying content-type with OSS across storage providers

This feature will be useful for people who want to view files via the browser http or https protocol.

Screenshots

Before After
... ...

Checklist

Important

Please review the checklist below before submitting your pull request.

  • 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

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. 💪 enhancement New feature or request 📚 documentation Improvements or additions to documentation labels Mar 31, 2025
@crazywoola crazywoola requested review from laipz8200 and Copilot April 2, 2025 13:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for specifying the content type when saving files to various OSS storage providers, allowing browsers to correctly interpret file formats.

  • Update storage interface (and mock) method signatures to accept an additional content_type parameter
  • Propagate the content_type parameter in all storage implementations and update file service calls accordingly

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
api/tests/unit_tests/oss/__mock/volcengine_tos.py Updated mock's put_object signature to include content_type
api/services/file_service.py Updated calls to storage.save to pass mimetype in upload methods
api/extensions/storage/volcengine_tos_storage.py Added content_type parameter to save and passed it to client put_object
api/extensions/storage/tencent_cos_storage.py Forwarded content_type via metadata in put_object call
api/extensions/storage/supabase_storage.py Updated upload to pass file_options with content_type
api/extensions/storage/oracle_oci_storage.py Added default content_type to the save method
api/extensions/storage/opendal_storage.py Included content_type in write call using a default when not provided
api/extensions/storage/huawei_obs_storage.py Updated putObject to include headers for content_type
api/extensions/storage/google_cloud_storage.py Passed content_type to blob.upload_from_file
api/extensions/storage/base_storage.py Updated abstract save signature to include content_type
api/extensions/storage/baidu_obs_storage.py Forwarded content_type to the client’s put_object call
api/extensions/storage/azure_blob_storage.py Added metadata with Content-Type during blob upload
api/extensions/storage/aws_s3_storage.py Set a default content_type and passed it in put_object call
api/extensions/storage/aliyun_oss_storage.py Updated put_object call to pass headers with content_type
api/extensions/ext_storage.py Updated wrapper save to forward the content_type parameter
api/core/tools/tool_file_manager.py Modified storage.save calls to include mimetype in file uploads
Comments suppressed due to low confidence (2)

api/extensions/storage/supabase_storage.py:32

  • [nitpick] Consider using consistent casing for the content type header key, for example 'Content-Type', to align with other storage provider implementations.
file_options = {"content-type": content_type} if content_type else None

api/extensions/storage/huawei_obs_storage.py:23

  • [nitpick] Verify that the header key for specifying content type matches the expected API format; consider using 'Content-Type' if that aligns with documentation.
headers = {"contentType": content_type} if content_type else None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 documentation Improvements or additions to documentation 💪 enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant