Skip to content

Make fingerprinting part of FileSource #738

@Acconut

Description

@Acconut

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions