Files
discourse/spec/lib/file_store
Alan Guo Xiang Tan 92b6c95f39 FIX: Set tagging_directive to "REPLACE" in S3Helper#copy (#37710)
What is the problem?

When `s3_enable_access_control_tags` is enabled, S3 uploads are tagged
with a configurable access control tag (default key: `discourse:acl`) to
indicate visibility. During multipart upload completion and file copies,
`S3Helper#copy` receives a `tagging` option with the desired tags for
the destination object. However, AWS S3 defaults `tagging_directive` to
"COPY", which preserves the source object's tags instead of applying the
new ones. This causes uploads to retain incorrect access control tags
after being copied.

What is the solution?

Set `tagging_directive: "REPLACE"` in `S3Helper#copy` whenever
`options[:tagging]` is present. This mirrors the existing
`metadata_directive: "REPLACE"` pattern already used for metadata and
tells the S3 API to apply the provided tags to the destination object.
2026-02-11 15:10:00 +08:00
..