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

Make fingerprinting part of FileSource #738

Open
Acconut opened this issue Dec 19, 2024 · 0 comments
Open

Make fingerprinting part of FileSource #738

Acconut opened this issue Dec 19, 2024 · 0 comments

Comments

@Acconut
Copy link
Member

Acconut commented Dec 19, 2024

Currently, fingerprints are calculated through the function that is passed in through the fingerprint option, defaulting to following implementation:

export default function fingerprint(file, options) {
if (isReactNative()) {
return Promise.resolve(reactNativeFingerprint(file, options))
}
return Promise.resolve(
['tus-br', file.name, file.type, file.size, file.lastModified, options.endpoint].join('-'),
)
}
function reactNativeFingerprint(file, options) {
const exifHash = file.exif ? hashCode(JSON.stringify(file.exif)) : 'noexif'
return ['tus-rn', file.name || 'noname', file.size || 'nosize', exifHash, options.endpoint].join(
'/',
)
}

As can be seen in the code, the fingerprint function has to differentiate between the different types of sources that tus-js-client can handle. For example, it needs to handle React Native files differently than File/Blob instances. In addition, it does not contain proper handling for streaming sources.

Generating a fingerprint should not be handled in one central function but be delegated to the FileSource instances, which handle the specific access to different input types. These instance know best how to compute the most accurate fingerprint.

That being said, we should still provider users with the ability to influence the fingerprint and add just information in it.

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

No branches or pull requests

1 participant