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 };
EventHookβ
type EventHook<T> = (cb: (obj: T, options: CreateOptions) => void, id?: string) => void;
CancellableHookβ
type CancellableHook<T> = (cb: (obj: T, options: CreateOptions) => boolean | void | Promise<boolean | void>, id?: string) => void;
ItemCancellableEventHookβ
type ItemCancellableEventHook = CancellableHook<BatchItem>;
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 {}
ResumeStartEventDataβ
interface TusResumeStartEventData {
url: string;
item: BatchItem;
resumeHeaders?: Record<string, string>;
}
TusResumeStartEventResponseβ
type TusResumeStartEventResponse = void | boolean | {
url?: string;
resumeHeaders?: Record<string, string>;
};
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,
}
RemovePreviewMethodβ
type RemovePreviewMethod = (id: string) => void;
PreviewItemβ
type PreviewItem = {
id: string;
url: string;
name: string;
type: PreviewType;
isFallback: boolean;
removePreview: RemovePreviewMethod;
props: Record<string, unknown>;
};
MockOptionsβ
interface MockOptions {
delay?: number;
fileSize?: number;
progressIntervals?: number[];
response?: any;
}
PreSendDataβ
export interface PreSendData {
items: BatchItem[];
options: CreateOptions;
}
PreSendResponseβ
type PreSendResponse = { items?: BatchItem[]; options?: CreateOptions } | boolean | void;
PreviewOptionsβ
type FallbackMethod = (file: FileLike) => FallbackType | void;
enum PreviewType {
IMAGE = "image",
VIDEO = "video",
}
type PreviewComponentPropsMethod = (item: BatchItem, url: string, type: PreviewType) => Record<string, unknown>;
type PreviewComponentPropsOrMethod = Record<string, unknown> | PreviewComponentPropsMethod;
interface PreviewOptions {
rememberPreviousBatches?: boolean;
loadFirstOnly?: boolean;
maxPreviewImageSize?: number;
maxPreviewVideoSize?: number;
fallbackUrl?: string | FallbackMethod;
imageMimeTypes?: string[];
videoMimeTypes?: string[];
previewComponentProps?: PreviewComponentPropsOrMethod;
}
EventCallbackβ
type EventCallback = (...args: any[]) => unknown | void;
OffMethodβ
type OffMethod = (name: unknown, cb?: EventCallback) => void;
OnAndOnceMethodβ
type OnAndOnceMethod = (name: unknown, cb: EventCallback) => OffMethod;