mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Add missing definitions to tus-js-client (#30384)
This commit is contained in:
committed by
Pranav Senthilnathan
parent
305cb040cd
commit
31fc92ecd3
Vendored
+8
-1
@@ -1,12 +1,14 @@
|
||||
// Type definitions for tus-js-client 1.4
|
||||
// Type definitions for tus-js-client 1.5
|
||||
// Project: https://github.com/tus/tus-js-client/
|
||||
// Definitions by: Kevin Somers-Higgins <https://github.com/kevhiggins>
|
||||
// Marius Kleidl <https://github.com/Acconut>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface UploadOptions {
|
||||
endpoint: string;
|
||||
fingerprint?: string;
|
||||
resume?: boolean;
|
||||
metadata?: { [key: string]: string };
|
||||
onProgress?: ((bytesSent: number, bytesTotal: number) => void) | null;
|
||||
onChunkComplete?: ((chunkSize: number, bytesAccepted: number, bytesTotal: number) => void) | null;
|
||||
onSuccess?: (() => void) | null;
|
||||
@@ -18,6 +20,7 @@ export interface UploadOptions {
|
||||
uploadSize?: number | null;
|
||||
overridePatchMethod?: boolean;
|
||||
retryDelays?: number[];
|
||||
removeFingerprintOnSuccess?: boolean;
|
||||
}
|
||||
|
||||
export class Upload {
|
||||
@@ -30,3 +33,7 @@ export class Upload {
|
||||
start(): void;
|
||||
abort(): void;
|
||||
}
|
||||
|
||||
export const isSupported: boolean;
|
||||
export const canStoreURLs: boolean;
|
||||
export const defaultOptions: UploadOptions;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
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",
|
||||
});
|
||||
@@ -8,6 +12,9 @@ const upload = new Tus.Upload(file, {
|
||||
endpoint: "",
|
||||
fingerprint: "fingerprint",
|
||||
resume: true,
|
||||
metadata: {
|
||||
filename: "foo.txt"
|
||||
},
|
||||
onProgress: (bytesSent: number, bytesTotal: number) => {
|
||||
const percentage = (bytesSent / bytesTotal * 100).toFixed(2);
|
||||
console.log(bytesSent, bytesTotal, percentage + "%");
|
||||
@@ -25,7 +32,8 @@ const upload = new Tus.Upload(file, {
|
||||
uploadUrl: "",
|
||||
uploadSize: 50,
|
||||
overridePatchMethod: true,
|
||||
retryDelays: [10, 20, 50]
|
||||
retryDelays: [10, 20, 50],
|
||||
removeFingerprintOnSuccess: true
|
||||
});
|
||||
|
||||
upload.start();
|
||||
|
||||
Reference in New Issue
Block a user