Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy object does not update content type #611

Closed
2 tasks done
ibash opened this issue Jan 10, 2025 · 4 comments · Fixed by #622
Closed
2 tasks done

Copy object does not update content type #611

ibash opened this issue Jan 10, 2025 · 4 comments · Fixed by #622
Labels
bug Something isn't working released

Comments

@ibash
Copy link

ibash commented Jan 10, 2025

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Case 1:
Steps:

  1. Copy object to a new key with a new content-type
  2. Curl the url of the new key
  3. Inspect the object in the supabase dashboard

Expected:
content-type header returned from curl are the new content type
mimetype in supabase is updated

Actual:
content-type header returned from curl is the old content type
mimetype in supabase is updated
In this case the content-type and supabase mimetype don't match

Case 2:
Steps:

  1. Copy object to the same key, but with the same content-type
  2. Curl the url of the key
  3. Inspect the object in the supabase dashboard

Expected:
content-type header returned from curl are the new content type
mimetype in supabase is updated

Actual:
Neither the content-type header or the mimetype are updated, they're both the old value

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

Content-type when curling and mimetype in supabase are both updated.

Additional context

This is a continuation of #580, but creating a new issue so it's not missed since that was marked completed.

@ibash ibash added the bug Something isn't working label Jan 10, 2025
@fenos
Copy link
Contributor

fenos commented Jan 16, 2025

Hey @ibash strange, we have a test covering this:
https://github.com/supabase/storage/blob/master/src/test/s3-protocol.test.ts#L969

Will investigate further

@ibash-corpusant
Copy link

In the test the key has changed, whereas I'm trying to update the same key. I think also when we ran it against s3 it might not have updated correctly on the s3 side (I can't recall). Thanks!

@fenos
Copy link
Contributor

fenos commented Jan 21, 2025

Created a PR to fix this! @ibash thanks a lot for the report!

Copy link

🎉 This issue has been resolved in version 1.18.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants