Skip to main content

Types

info

For Batch and BatchItem see: Entities Page

UploadyContextType​

type UploadyContextType = {
getInternalFileInput: () => InputRef | undefined;
setExternalFileInput: (inputRef: InputRef) => void;
getIsUsingExternalInput: () => boolean;
hasUploader: () => boolean;
showFileUpload: (options?: UploadOptions) => void;
upload: AddUploadFunction;
processPending: (uploadOptions?: UploadOptions) => void;
clearPending: () => void;
setOptions: (options: CreateOptions) => void;
getOptions: () => CreateOptions;
on: OnAndOnceMethod;
once: OnAndOnceMethod;
off: OffMethod;
abort: (id?: string) => void;
abortBatch: (id: string) => void;
getExtension: (name: unknown) => Record<string, unknown>;
};

Destination​

type Destination = {
url?: string;
filesParamName?: string;
params?: Record<string, unknown>;
headers?: Record<string, unknown>;
method?: string;
};

FormatServerResponseMethod​

type FormatServerResponseMethod = (response: string, status: number, headers: Record<string, string> | undefined) => unknown;

FormatParamGroupNameMethod​

type FormatParamGroupNameMethod = (index: number, paramName: string) => string;

FileFilterMethod​

type FileFilterMethod = (file: File | string, index: number, files: File[] | string[]) => boolean | Promise<boolean | undefined> | undefined;

IsSuccessfulCall​

export type IsSuccessfulCall = (xhr: XMLHttpRequest) => boolean;

SendOptions​

interface SendOptions  {
method: string;
paramName: string;
params?: Record<string, unknown>;
headers?: Record<string, unknown>;
forceJsonResponse?: boolean;
withCredentials?: boolean;
formatGroupParamName?: FormatParamGroupNameMethod;
sendWithFormData?: boolean;
formDataAllowUndefined?: boolean;
formatServerResponse?: FormatServerResponseMethod;
isSuccessfulCall?: IsSuccessfulCall;
}

UploadInfo​

type UploadInfo = string | FileLike | BatchItem;

UploadAddMethod​

type UploadAddMethod = (files: UploadInfo | UploadInfo[], addOptions?: UploadOptions) => Promise<void>

UploaderType​

export type UploaderType = {
id: string;
update: (updateOptions: CreateOptions) => UploaderType;
add: UploadAddMethod;
upload: (uploadOptions?: UploadOptions) => void;
abort: (id?: string) => void;
abortBatch: (id: string) => void;
getOptions: () => CreateOptions;
getPending: () => PendingBatch[];
clearPending: () => void;
on: OnAndOnceMethod;
once: OnAndOnceMethod;
off: OffMethod;
registerExtension: RegisterExtensionMethod;
getExtension: (name: unknown) => Record<string, unknown>;
}

UploaderListeners​

type UploaderListeners = { [key: string]: EventCallback };

UploadOptions​

interface UploadOptions extends Partial<SendOptions>{
autoUpload?: boolean;
clearPendingOnAdd?: boolean;
formatGroupParamName?: FormatParamGroupNameMethod;
grouped?: boolean;
maxGroupSize?: number;
fileFilter?: FileFilterMethod;
destination?: Destination;
fastAbortThreshold?: number;
}

UploaderEnhancer​

type UploaderEnhancer = (uploader: UploaderType, trigger: Trigger<any>) => UploaderType;

OnProgress​

type OnProgress = (e: SenderProgressEvent, objs: Record<string, unknown>[]) => void;

UploadData​

type UploadData = {
status: number;
state: FILE_STATES;
response: any;
};

See: FILE_STATES

SendResult​

type SendResult = {
request: Promise<UploadData>;
abort: () => boolean;
senderType: string;
};

SendMethod​

type SendMethod = (item: BatchItem[], url: string | undefined, options: SendOptions, onProgress?: OnProgress) => SendResult;

CreateOptions​

interface CreateOptions extends UploadOptions {
enhancer?: UploaderEnhancer;
concurrent?: boolean;
maxConcurrent?: number;
send?: SendMethod;
}

InputRef​

type InputRef = { current: HTMLInputElement | null };

ItemCancellableEventHook​

type ItemCancellableEventHook = CancellableHook<BatchItem>;

CancellableHook​

type CancellableHook<T> = (cb: (obj: T) => boolean | void, id?: string) => void;

EventHookWithState​

type EventHookWithState<T> = ((cb?: (obj: T) => void, id?: string) => T) & ((id?: string) => T);

BatchEventHook​

type BatchEventHook = EventHook<Batch>;

BatchCancellableEventHook​

type BatchCancellableEventHook = CancellableHook<Batch>;

ItemEventHook​

type ItemEventHook = EventHook<BatchItem>;

ItemCancellableEventHook​

type ItemCancellableEventHook = CancellableHook<BatchItem>;

ItemEventHookWithState​

type ItemEventHookWithState = EventHookWithState<BatchItem>;

ChunkEventData​

type ChunkEventData = {
id: string;
start: number;
end: number;
index: number;
attempt: number;
};

ChunkStartEventData​

type ChunkStartEventData = {
item: BatchItem;
chunk: ChunkEventData;
chunkItem: BatchItem;
sendOptions: SendOptions;
url: string;
remainingCount: number,
totalCount: number,
onProgress: OnProgress
};

ChunkFinishEventData​

type ChunkFinishEventData = {
item: BatchItem;
chunk: ChunkEventData;
uploadData: UploadData;
};

ChunkedOptions​

interface ChunkedOptions {
chunked?: boolean;
chunkSize?: number;
retries?: number;
parallel?: number;
}

ChunkedUploadyProps​

interface ChunkedUploadyProps extends UploadyProps, ChunkedOptions {}

TusOptions​

interface TusOptions extends ChunkedOptions {
version?: string;
featureDetection?: boolean;
featureDetectionUrl?: string | null;
onFeaturesDetected?: (extensions: string[]) => TusOptions | void;
resume?: boolean;
deferLength?: boolean;
overrideMethod?: boolean;
sendDataOnCreate?: boolean;
storagePrefix?: string;
lockedRetryDelay?: number;
forgetOnSuccess?: boolean;
ignoreModifiedDateInStorage?: boolean;
}

TusUploadyProps​

interface TusUploadyProps extends UploadyProps, TusOptions {}

PasteUploadData​

type PasteUploadData = { count: number };

PasteUploadHandler​

type PasteUploadHandler = (data: PasteUploadData) => void;

PasteCompProps​

interface PasteCompProps {
className?: string;
id?: string;
children?: JSX.Element[] | JSX.Element | string;
extraProps?: Record<string, unknown>;
onPasteUpload?: PasteUploadHandler,
}

PreviewItem​

type PreviewItem = {
id: string;
url: string;
name: string;
type: PreviewType;
isFallback: boolean;
props: Record<string, unknown>;
};

PreviewData​

type PreviewData = {
previews: PreviewItem[];
clearPreviews: () => void;
};

MockOptions​

interface MockOptions {
delay?: number;
fileSize?: number;
progressIntervals?: number[];
response?: any;
}

PreSendResponse​

type PreSendResponse = { items?: BatchItem[]; options?: CreateOptions } | boolean | void;