To update metadata like Cache-Control for S3 objects, you have to use the CopyObject method with the MetadataReplace flag set
to REPLACE.
import { S3 } from "aws-sdk";import { CopyObjectRequest } from "aws-sdk/clients/s3";const s3 = new S3({ region: "eu-central-1" });async function updateMetadata(bucket: string, key: string) { const params: CopyObjectRequest = { Bucket: bucket, Key: key, CopySource: `${bucket}/${key}`, MetadataDirective: "REPLACE", CacheControl: "max-age=0, s-maxage=3600", ContentType: "application/json" // ... other metadata }; await s3.copyObject(params).promise();}