Skip to content

feat(services/oss): support content_encoding in write operations#7658

Open
ITpandaffm wants to merge 1 commit into
apache:mainfrom
ITpandaffm:feat/oss-content-encoding
Open

feat(services/oss): support content_encoding in write operations#7658
ITpandaffm wants to merge 1 commit into
apache:mainfrom
ITpandaffm:feat/oss-content-encoding

Conversation

@ITpandaffm
Copy link
Copy Markdown

Which issue does this PR close?

Closes #7656.

Rationale for this change

The OSS backend currently does not honor OpWrite::content_encoding(), even
though the write option already exists and other object storage backends such as
S3 and GCS support it.

Users who upload gzip/br/deflate objects to Aliyun OSS through OpenDAL cannot
preserve the Content-Encoding metadata. This breaks CDN/browser transparent
decompression for compressed static objects.

What changes are included in this PR?

  • core/services/oss/src/backend.rs
    • Set write_with_content_encoding: true in the OSS capability table.
  • core/services/oss/src/core.rs
    • Import http::header::CONTENT_ENCODING.
    • Forward args.content_encoding() in shared write metadata headers, covering
      PutObject and AppendObject.
    • Add a content_encoding parameter to oss_initiate_upload and set the
      header on InitiateMultipartUpload.
  • core/services/oss/src/writer.rs
    • Pass self.op.content_encoding() into oss_initiate_upload for multipart
      writes.

Are there any user-facing changes?

Yes. OSS now advertises write_with_content_encoding, and
op.write_with(...).content_encoding(...) will preserve Content-Encoding
metadata on written objects.

Existing users who do not set content_encoding are unaffected.

Tests

  • cargo fmt --check
  • cargo check -p opendal --features services-oss --no-default-features
  • cargo clippy -p opendal --features services-oss --no-default-features -- -D warnings
  • cargo test -p opendal-service-oss --no-default-features

Signed-off-by: 旻序 <fuming.ffm@alibaba-inc.com>
@ITpandaffm ITpandaffm requested a review from Xuanwo as a code owner June 1, 2026 08:21
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. releases-note/feat The PR implements a new feature or has a title that begins with "feat" labels Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

new feature: feat(services/oss): support content_encoding for write operations

1 participant