opendal icon indicating copy to clipboard operation
opendal copied to clipboard

feat(services/b2): Add user defined metadata support

Open zhan7236 opened this issue 4 weeks ago • 2 comments

Which issue does this PR close?

Part of #4842.

Rationale for this change

This PR adds user defined metadata support for the Backblaze B2 service (b2), which allows users to write and read custom metadata along with their files.

What changes are included in this PR?

  • Add X_BZ_INFO_PREFIX constant ("X-Bz-Info-") in core.rs for user metadata HTTP header prefix
  • Add file_info field to File struct to parse user metadata from B2 API responses
  • Add user metadata headers support in upload_file function with URL-encoded values
  • Update parse_file_info function to decode and return user metadata
  • Enable write_with_user_metadata capability in the service

Are there any user-facing changes?

Yes, users can now use write_with().user_metadata() to set custom metadata when writing files to Backblaze B2 service, and retrieve them via stat().

Example:

let metadata = vec![("location".to_string(), "everywhere".to_string())];
op.write_with(&path, content)
    .user_metadata(metadata)
    .await?;

let meta = op.stat(&path).await?;
let user_meta = meta.user_metadata();

zhan7236 avatar Dec 01 '25 06:12 zhan7236

Maintainer triggered full CI with repository secrets. Please monitor the mirrored CI PR for results: https://github.com/apache/opendal/pull/6846 Re-applying the label will refresh this mirror.

github-actions[bot] avatar Dec 01 '25 09:12 github-actions[bot]

Sorry for the noise, I’m working on a workflow so we can test this PR properly.

Xuanwo avatar Dec 01 '25 10:12 Xuanwo