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

fix: allow copying objects to same destination and overwrite metadata #622

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

fenos
Copy link
Contributor

@fenos fenos commented Jan 21, 2025

What kind of change does this PR introduce?

Bug fix / Feature

What is the current behavior?

Copying objects to the same destination is not supported

What is the new behavior?

  • Allow copying objects to same destination
  • Allow overwriting cacheControl & mimetype
  • Support HTTP protocol and S3 Protocol
  • Return copied object in the response

Fixes #611

@fenos fenos force-pushed the fix/copy-object-same-path branch from 0717258 to 61c5816 Compare January 21, 2025 11:54
@coveralls
Copy link

coveralls commented Jan 21, 2025

Pull Request Test Coverage Report for Build 12904690960

Details

  • 58 of 61 (95.08%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 77.414%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/storage/uploader.ts 10 13 76.92%
Totals Coverage Status
Change from base Build 12886525928: 0.1%
Covered Lines: 15225
Relevant Lines: 19509

💛 - Coveralls

@fenos fenos force-pushed the fix/copy-object-same-path branch 3 times, most recently from 9311788 to 3acbc34 Compare January 21, 2025 16:51
@fenos fenos force-pushed the fix/copy-object-same-path branch from 3acbc34 to bb658f8 Compare January 22, 2025 09:02
@fenos fenos merged commit ddc5163 into master Jan 22, 2025
1 check passed
@fenos fenos deleted the fix/copy-object-same-path branch January 22, 2025 12:05
Copy link

🎉 This PR is included in version 1.18.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@ibash
Copy link

ibash commented Jan 22, 2025

Hi! Do I need to wait for this to get deployed? I just tried this but am still not getting an updated content-type.

My request looks like:

const request = new Request(
  'https://my-supabase-url.com/storage/v1/object/copy',
  {
    method: "POST",
    headers: {
      'apikey': process.env.SUPABASE_SERVICE_KEY,
      'authorization': `Bearer ${process.env.SUPABASE_SERVICE_KEY}`,
      'x-upsert': 'true',
      'content-type': 'application/json',
      'x-metadata': Buffer.from(
        JSON.stringify({
          newMetadata: 'test1',
          mimetype: 'audio/mp4',
        })
      ).toString('base64')
    },
    body: JSON.stringify({
      bucketId: 'riffs',
      sourceKey: '65d46064-344b-41bc-820d-0b24aa08c684/audio/001bb7c8-07f4-41da-ba8c-b949fcd17b36.m4a',
      destinationKey: '65d46064-344b-41bc-820d-0b24aa08c684/audio/001bb7c8-07f4-41da-ba8c-b949fcd17b36.m4a',
      metadata: {
        cacheControl: 'max-age=10',
        mimetype: 'audio/mp4',
      },
      copyMetadata: false,
    }),
  }
);

The source object has an content type of text/plain and I'm trying to correct it to audio/mp4.

Am I doing something wrong?

@fenos
Copy link
Contributor Author

fenos commented Jan 22, 2025

Hi @ibash it will be deployed either tomorrow or early next week, will let you know when it lands

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy object does not update content type
4 participants