From a6903cbd65e05a14bbfef00c0ae3ca4ebaa2145a Mon Sep 17 00:00:00 2001 From: Marius Kleidl Date: Wed, 2 Oct 2024 15:11:40 +0200 Subject: [PATCH 1/3] Mention limitation in `HttpRequest#getHeader` See https://github.com/tus/tus-js-client/issues/729 --- docs/api.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/api.md b/docs/api.md index 5d28a921..21e1c01a 100644 --- a/docs/api.md +++ b/docs/api.md @@ -333,10 +333,17 @@ interface HttpRequest { getMethod(): string; getURL(): string; + // Set a header from this request. setHeader(header: string, value: string); + + // Retrieve a header value from this request. + // Note: In browser environments this method can only return headers explicitly set by + // tus-js-client or users through the above `setHeader` method. It cannot return headers that are + // implicitly added by the browser (e.g. Content-Length) due to a security related API limitation. getHeader(header: string): string | undefined; setProgressHandler((bytesSent: number): void): void; + // Send the HTTP request with the provided request body. The value of the request body depends // on the platform and what `fileReader` implementation is used. With the default `fileReader`, // `body` can be From ad687710d7169ebe55744588fb8067be7a82e871 Mon Sep 17 00:00:00 2001 From: Marius Kleidl Date: Wed, 2 Oct 2024 15:17:15 +0200 Subject: [PATCH 2/3] Correct documentation of `PreviousUpload` interface https://github.com/tus/tus-js-client/issues/726 --- docs/api.md | 8 ++++++-- lib/index.d.ts | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index 21e1c01a..9a62808e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -389,6 +389,8 @@ interface ListEntry { metadata: object creationTime: string urlStorageKey: string + uploadUrl: string | null + parallelUploadUrls: string[] | null } ``` @@ -504,7 +506,7 @@ tus.Upload.terminate(url) ## tus.Upload#findPreviousUploads() -Query the URL storage using the input file's fingerprint to retrieve a list of uploads for the input file, which have previously been started by the user. If you want to resume one of this uploads, pass the corresponding object to `tus.Upload#resumeFromPreviousUpload` before calling `tus.Upload#start`. +Query the URL storage using the input file's fingerprint to retrieve a list of uploads for the input file, which have previously been started by the user. If you want to resume one of these uploads, pass the corresponding object to `tus.Upload#resumeFromPreviousUpload` before calling `tus.Upload#start`. The function returns a `Promise`, which resolves to a list with following structure: @@ -513,9 +515,11 @@ findPreviousUploads(): Promise>; interface PreviousUpload { size: number | null; - metadata: object + metadata: object; creationTime: string; urlStorageKey: string; + uploadUrl: string | null; + parallelUploadUrls: string[] | null; } ``` diff --git a/lib/index.d.ts b/lib/index.d.ts index 4a94eea2..bad011f4 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -77,6 +77,9 @@ interface PreviousUpload { size: number | null metadata: { [key: string]: string } creationTime: string + urlStorageKey: string + uploadUrl: string | null + parallelUploadUrls: string[] | null } interface FileReader { From f7b3bf79e6a23dbd4643956529a73ab6ef7052a3 Mon Sep 17 00:00:00 2001 From: Marius Kleidl Date: Wed, 2 Oct 2024 15:34:17 +0200 Subject: [PATCH 3/3] Fix link to Cordova demo --- docs/api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index 9a62808e..0a5e7a90 100644 --- a/docs/api.md +++ b/docs/api.md @@ -444,7 +444,7 @@ Depending on the platform, the `file` argument must be an instance of the follow - inside browser: `File`, `Blob`, or [`Reader`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader) - inside Node.js: `Buffer` or `Readable` stream -- inside Cordova: `File` object from a `FileEntry` (see [demo](demos/cordova/www/js/index.js)) +- inside Cordova: `File` object from a `FileEntry` (see [demo](/demos/cordova/www/js/index.js)) The `options` argument will be merged deeply with `tus.defaultOptions`. See its documentation for more details.