Skip to content

Conversation

@kha333n
Copy link

@kha333n kha333n commented Jul 24, 2025

Pull Request Description

Problem

The Uppy Tus plugin generates fingerprints for files based on their id and endpoint, which means identical files (same content and name) uploaded to different contexts, such as separate projects, are treated as the same file. This prevents scoping uploads to specific projects, as the plugin cannot differentiate between identical files uploaded to distinct projects. For example, uploading file.jpg to "project-123" and "project-456" results in the same fingerprint, causing conflicts in resumable uploads or incorrect file associations.

Solution

To address this, I introduced a new fingerprintExtra option to the Tus plugin. This option allows users to include additional metadata, such as a project ID, in the fingerprint calculation. By appending this extra data to the fingerprint, identical files uploaded to different projects generate unique fingerprints, ensuring proper scoping and preventing conflicts. For example, adding fingerprintExtra: 'project-123' ensures the fingerprint is unique to that project, even for identical files.

Changes

  • Modified packages/@uppy/tus/src/index.ts:
    • Added fingerprintExtra as an optional configuration option in the TusOpts type.
    • Updated the uploadOptions.fingerprint assignment to use the getFingerprint function with opts.fingerprintExtra.
  • Modified packages/@uppy/tus/src/getFingerprint.ts:
    • Enhanced the getFingerprint function to accept an extraKeys parameter and append the specified metadata values to the fingerprint, joined by colons.
    • Ensured compatibility with existing behavior by making extraKeys optional and handling missing metadata gracefully.
  • Added Unit Tests in packages/@uppy/tus/index.test.ts:
    • Created a describe block for getFingerprint with tests covering:
      • Including extra metadata in the fingerprint.
      • Handling cases where fingerprintExtra is not provided.
      • Supporting multiple extra keys.
      • Handling missing metadata keys.
      • Converting metadata values to strings.
      • Supporting special characters in metadata.

Example

    uppy.use(Tus, {
      endpoint: 'https://tus.example.com',
      fingerprintExtra: 'project-123',
    });

@changeset-bot
Copy link

changeset-bot bot commented Jul 24, 2025

⚠️ No Changeset found

Latest commit: b162588

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Murderlon
Copy link
Member

This prevents scoping uploads to specific projects, as the plugin cannot differentiate between identical files uploaded to distinct projects. For example, uploading file.jpg to "project-123" and "project-456" results in the same fingerprint, causing conflicts in resumable uploads or incorrect file associations.

What do you mean projects? How do you achieve a situation where they are not unique?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants