|
@@ -52,7 +52,12 @@ export interface XhrUploadOpts<M extends Meta, B extends Body>
|
|
|
limit?: number
|
|
|
responseType?: XMLHttpRequestResponseType
|
|
|
withCredentials?: boolean
|
|
|
- onBeforeRequest?: FetcherOptions['onBeforeRequest']
|
|
|
+ onBeforeRequest?: (
|
|
|
+ xhr: XMLHttpRequest,
|
|
|
+ retryCount: number,
|
|
|
+ /** The files to be uploaded. When `bundle` is `false` only one file is in the array. */
|
|
|
+ files: UppyFile<M, B>[],
|
|
|
+ ) => void | Promise<void>
|
|
|
shouldRetry?: FetcherOptions['shouldRetry']
|
|
|
onAfterResponse?: FetcherOptions['onAfterResponse']
|
|
|
getResponseData?: (xhr: XMLHttpRequest) => B | Promise<B>
|
|
@@ -194,13 +199,16 @@ export default class XHRUpload<
|
|
|
*/
|
|
|
this.#getFetcher = (files: UppyFile<M, B>[]) => {
|
|
|
return async (
|
|
|
- url: Parameters<typeof fetcher>[0],
|
|
|
- options: NonNullable<Parameters<typeof fetcher>[1]>,
|
|
|
+ url: string,
|
|
|
+ options: Omit<FetcherOptions, 'onBeforeRequest'> & {
|
|
|
+ onBeforeRequest?: Opts<M, B>['onBeforeRequest']
|
|
|
+ },
|
|
|
) => {
|
|
|
try {
|
|
|
const res = await fetcher(url, {
|
|
|
...options,
|
|
|
- onBeforeRequest: this.opts.onBeforeRequest,
|
|
|
+ onBeforeRequest: (xhr, retryCount) =>
|
|
|
+ this.opts.onBeforeRequest?.(xhr, retryCount, files),
|
|
|
shouldRetry: this.opts.shouldRetry,
|
|
|
onAfterResponse: this.opts.onAfterResponse,
|
|
|
onTimeout: (timeout) => {
|