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

feat: Signed Upload URL for TUS #461

Merged
merged 1 commit into from
May 2, 2024
Merged

Conversation

fenos
Copy link
Contributor

@fenos fenos commented Apr 25, 2024

What kind of change does this PR introduce?

Feature

What is the current behavior?

Signed upload URL were not supported for the TUS protocol

What is the new behavior?

Supporting signed upload URL for the TUS protocol, allowing non-authenticated users to upload via TUS by having this time-limited URL

Example client implementation:

const { data, error } = await supabase
  .storage
  .from('avatars')
  .createSignedUploadUrl('folder/cat.jpg')


const upload = new tus.Upload(file, {
  endpoint: `${localServerAddress}/upload/resumable/sign`,
  headers: {
    'x-signature': data.token,
  },
  metadata: {
    bucketName: 'avatars',
    objectName: 'folder/cat.jpg',
    contentType: 'image/jpeg',
    cacheControl: '3600',
  },
  onError: function (error) {
    console.log('Failed because: ' + error)
  },
  onSuccess: () => {
    console.log('success')
  },
})

upload.start()

Additional context

Implementation details:

Tus URL for signed uploads: /upload/resumable/sign
Signature header: x-signature

@coveralls
Copy link

coveralls commented Apr 25, 2024

Pull Request Test Coverage Report for Build 8897871043

Details

  • 234 of 262 (89.31%) changed or added relevant lines in 10 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.2%) to 79.275%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/http/plugins/jwt.ts 1 2 50.0%
src/http/routes/tus/lifecycle.ts 32 34 94.12%
src/storage/object.ts 28 32 87.5%
src/http/routes/tus/index.ts 152 173 87.86%
Files with Coverage Reduction New Missed Lines %
src/storage/object.ts 2 90.82%
Totals Coverage Status
Change from base Build 8813009433: 0.2%
Covered Lines: 12032
Relevant Lines: 15041

💛 - Coveralls

@fenos fenos force-pushed the feat/tus-signed-upload-url-support branch 2 times, most recently from 24cb1d0 to e30eee8 Compare April 30, 2024 08:30
@fenos fenos force-pushed the feat/tus-signed-upload-url-support branch from e30eee8 to dbb9185 Compare April 30, 2024 15:55
@fenos fenos merged commit d431640 into master May 2, 2024
1 check passed
@fenos fenos deleted the feat/tus-signed-upload-url-support branch May 2, 2024 08:35
Copy link

github-actions bot commented May 2, 2024

🎉 This PR is included in version 1.2.0 🎉

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants