Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as Tus from 'tus-js-client';
const isSupported = Tus.isSupported;
const canStoreURLs = Tus.canStoreURLs;
const defaultChunkSize = Tus.defaultOptions.chunkSize;
const file = new File(["foo"], "foo.txt", {
type: "text/plain",
});
const upload = new Tus.Upload(file, {
endpoint: "",
fingerprint: (file: File) => file.name,
resume: true,
metadata: {
filename: "foo.txt"
},
onProgress: (bytesSent: number, bytesTotal: number) => {
const percentage = (bytesSent / bytesTotal * 100).toFixed(2);
console.log(bytesSent, bytesTotal, percentage + "%");
},