opendal
opendal copied to clipboard
feat(services/b2): Add user defined metadata support
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_PREFIXconstant ("X-Bz-Info-") incore.rsfor user metadata HTTP header prefix - Add
file_infofield toFilestruct to parse user metadata from B2 API responses - Add user metadata headers support in
upload_filefunction with URL-encoded values - Update
parse_file_infofunction to decode and return user metadata - Enable
write_with_user_metadatacapability 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();
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.
Sorry for the noise, I’m working on a workflow so we can test this PR properly.