Skip to content

swift: add metadata support - #10003

Open
ZacharyJo wants to merge 1 commit into
rclone:masterfrom
ZacharyJo:swift-metadata
Open

ZacharyJo wants to merge 1 commit into
rclone:masterfrom
ZacharyJo:swift-metadata

Conversation

@ZacharyJo

@ZacharyJo ZacharyJo commented Sep 29, 2026 •

Copy link
Copy Markdown

What does this change do?

Adds reading and writing of object metadata to the Swift backend, so that --metadata works for Swift.

  • Object.Metadata returns the Swift user metadata (X-Object-Meta-*) plus the standard system metadata (cache-control, content-disposition, content-language, content-type, mtime).
  • Object.Update and Object.Copy apply the metadata on upload and on server side copy, including the large object manifest path, so no extra requests are needed for a normal copy.
  • Server side copies send X-Fresh-Metadata so the metadata is replaced rather than merged with the source's, and --header-upload is applied to copies as well as uploads.
  • content-encoding is documented as read only: rclone's HTTP transport transparently decompresses a response carrying Content-Encoding: gzip, so writing that header would create objects rclone could not read back.
  • The backend now advertises ReadMetadata, WriteMetadata and UserMetadata, and MetadataInfo documents the system metadata keys.

Swift's metadata column in the overview table changes from - to RWU. This is done in docs/data/backends/swift.yaml, which generates the table.

Linked issue

Fixes #10002

This supersedes #8511, which only added read support and no longer applies cleanly. In that PR @albertony asked: "Swift could probably also support writing metadata (again similar to S3)?" - this change implements that.

For new or changed backends

go run ./fstest/test_all -backends swift passes:

2026/09/29 16:30:37 NOTICE: PASS: All tests finished OK in 19m18.508155541s

This covers TestSwiftAIO: and TestSwiftAIOsegments: (go test, vfs, operations ±fast-list, sync ±fast-list, bisync).

Note for anyone reproducing this on Apple Silicon: the openstackswift/saio image has no arm64 manifest, so it needs DOCKER_DEFAULT_PLATFORM=linux/amd64.

Checklist

  • This change is trivial OR it has been discussed and agreed in the linked issue.
  • I have read the contribution guidelines.
  • (If I used AI tools to help write this code) I have read and understood the AI-assisted contributions guidance, and I have tested and take ownership of this change myself.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • (Backend changes only) test_all passes for this backend and if submitting a new backend can provide a test account for the integration tester - see CONTRIBUTING.md.
  • This Pull Request is ready for review.

Before this change the Swift backend did not implement the metadata
interfaces, so --metadata had no effect: user metadata stored in
X-Object-Meta-* headers was neither read nor written, and it was lost
when copying or syncing between Swift and other remotes.

After this change the Swift backend supports reading and writing object
metadata:

- Object.Metadata exposes Swift user metadata plus the standard system
  metadata (Cache-Control, Content-Disposition, Content-Encoding,
  Content-Language, Content-Type and mtime).
- Object.Update and Object.Copy pass the metadata through to the upload
  and to the server side copy, including the large object manifest path,
  so no extra requests are needed for a normal copy.
- Server side copies send X-Fresh-Metadata so the metadata is replaced
  rather than merged with the source's, and --header-upload is applied to
  copies as well as uploads.
- MetadataInfo documents the system metadata keys and the backend now
  advertises the ReadMetadata, WriteMetadata and UserMetadata features.

content-encoding is documented as read only: rclone's HTTP transport
transparently decompresses a response carrying Content-Encoding: gzip,
so writing that header would create objects rclone could not read back.

For chunked uploads the metadata is only applied to the manifest object,
not to the segments, which are internal to the large object.

Unit tests have been added, and the documentation and the backend feature
list have been updated.
@ZacharyJo
ZacharyJo requested a review from ncw as a code owner September 29, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

swift: add object metadata support (read and write)

1 participant