View as Markdown

API reference: @salmonui/inputs/file-upload/xhr

XhrUploaderOptionsinterface

import type { XhrUploaderOptions } from '@salmonui/inputs/file-upload/xhr';
interface XhrUploaderOptions {
    readonly url: string | ((file: File) => string);
    readonly method?: string | undefined;
    readonly headers?: Readonly<Record<string, string>> | ((file: File) => Readonly<Record<string, string>>) | undefined;
    readonly fieldName?: string | undefined;
    readonly data?: Readonly<Record<string, string>> | ((file: File) => Readonly<Record<string, string>>) | undefined;
    readonly withCredentials?: boolean | undefined;
}
XhrUploaderOptions members (6)
NameSignatureDescription
urlreadonly url: string | ((file: File) => string);

Target URL, or a function of the file.

methodoptionalreadonly method?: string | undefined;

Default 'POST'.

headersoptionalreadonly headers?: Readonly<Record<string, string>> | ((file: File) => Readonly<Record<string, string>>) | undefined;

Request headers, or a function of the file (auth tokens, CSRF).

fieldNameoptionalreadonly fieldName?: string | undefined;

Multipart field name of the file. Default 'file'.

dataoptionalreadonly data?: Readonly<Record<string, string>> | ((file: File) => Readonly<Record<string, string>>) | undefined;

Extra multipart fields sent with each file.

withCredentialsoptionalreadonly withCredentials?: boolean | undefined;

Sends cookies cross-origin. Default false.