supabase / storage

S3 compatible object storage service that stores metadata in Postgres
https://supabase.com/docs/guides/storage
Apache License 2.0
811 stars 116 forks source link

Copy object does not update content type #580

Closed ibash closed 1 week ago

ibash commented 1 week ago

Bug report

Describe the bug

When copying an object via the S3 protocol, and specifying a new content-type, the object is not updated with the new content type.

To Reproduce

  1. Upload an object to supabase storage with content-type "text/plain"
  2. Overwrite the object via the s3 protocol, but specify an alternative content type like "audio/mp4"
import { S3Client, CopyObjectCommand } from "@aws-sdk/client-s3";

const client = new S3Client({
  forcePathStyle: true,
  region: "us-west-1",
  endpoint: "supabase-s3-endpoint",
  credentials: {
    accessKeyId: process.env.ACCESS_KEY_ID,
    secretAccessKey: process.env.SECRET_ACCESS_KEY,
  },
});

const bucket = 'my-bucket'
const key = 'my-key.m4a'

const command = new CopyObjectCommand({
  Bucket: bucket,
  CopySource: `${bucket}/${key}`,
  Key: key,
  ContentType: 'audio/mp4'
});

const data = await client.send(command);

console.log('data is ', data)

Expected behavior

After copying the object, the new object should have an update content-type. If you check via curl or via the supabase ui you'll see the content-type has not changed.

Additional context

I looked through the code and it seems like setting the new content-type isn't implemented, even though the docs say that it is supported: https://github.com/supabase/storage/blob/6b052d85b9f0c7eb2442a0377b49ca058a5809af/src/http/routes/s3/commands/copy-object.ts#L32 https://github.com/supabase/storage/blob/6b052d85b9f0c7eb2442a0377b49ca058a5809af/src/storage/protocols/s3/s3-handler.ts#L1020

https://supabase.com/docs/guides/storage/s3/compatibility

Screenshot 2024-11-01 at 5 55 42 PM
fenos commented 1 week ago

@ibash thanks a lot for reporting this! will send a PR asap

github-actions[bot] commented 1 week ago

:tada: This issue has been resolved in version 1.12.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: