Skip to content

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

Merged
Xuanwo merged 1 commit into
apache:mainfrom
ITpandaffm:feat/oss-content-encoding
Jun 2, 2026
Merged

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

Conversation

@ITpandaffm

Copy link
Copy Markdown
Contributor

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

@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
Signed-off-by: 旻序 <fuming.ffm@alibaba-inc.com>
@ITpandaffm ITpandaffm force-pushed the feat/oss-content-encoding branch from 3487521 to 7a05f92 Compare June 2, 2026 07:26

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 2, 2026
@Xuanwo Xuanwo merged commit 515f9f4 into apache:main Jun 2, 2026
102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer 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

2 participants