ant-design/components/upload/interface.tsx
Jinke Li 0240d126ec feat(Upload): add transformFile option for transform file before request (#18009)
* feat: add transformFile optionfor transform file before request

* feat: bump rc-upload 2.7.0

* feat(Upload): optimize doc
2019-08-04 12:18:46 +08:00

106 lines
2.8 KiB
TypeScript
Executable File

import * as React from 'react';
export type UploadFileStatus = 'error' | 'success' | 'done' | 'uploading' | 'removed';
export interface HttpRequestHeader {
[key: string]: string;
}
export interface RcFile extends File {
uid: string;
readonly lastModifiedDate: Date;
readonly webkitRelativePath: string;
}
export interface UploadFile {
uid: string;
size: number;
name: string;
fileName?: string;
lastModified?: number;
lastModifiedDate?: Date;
url?: string;
status?: UploadFileStatus;
percent?: number;
thumbUrl?: string;
originFileObj?: File | Blob;
response?: any;
error?: any;
linkProps?: any;
type: string;
}
export interface UploadChangeParam<T extends object = UploadFile> {
// https://github.com/ant-design/ant-design/issues/14420
file: T;
fileList: Array<UploadFile>;
event?: { percent: number };
}
export interface ShowUploadListInterface {
showRemoveIcon?: boolean;
showPreviewIcon?: boolean;
}
export interface UploadLocale {
uploading?: string;
removeFile?: string;
uploadError?: string;
previewFile?: string;
}
export type UploadType = 'drag' | 'select';
export type UploadListType = 'text' | 'picture' | 'picture-card';
type PreviewFileHandler = (file: File | Blob) => PromiseLike<string>;
type TransformFileHandler = (file: UploadFile) => string | Blob | File | PromiseLike<string | Blob | File>;
export interface UploadProps {
type?: UploadType;
name?: string;
defaultFileList?: Array<UploadFile>;
fileList?: Array<UploadFile>;
action?: string | ((file: RcFile) => string) | ((file: RcFile) => PromiseLike<string>);
directory?: boolean;
data?: object | ((file: UploadFile) => object);
headers?: HttpRequestHeader;
showUploadList?: boolean | ShowUploadListInterface;
multiple?: boolean;
accept?: string;
beforeUpload?: (file: RcFile, FileList: RcFile[]) => boolean | PromiseLike<void>;
onChange?: (info: UploadChangeParam) => void;
listType?: UploadListType;
className?: string;
onPreview?: (file: UploadFile) => void;
onRemove?: (file: UploadFile) => void | boolean | Promise<void | boolean>;
supportServerRender?: boolean;
style?: React.CSSProperties;
disabled?: boolean;
prefixCls?: string;
customRequest?: (option: object) => void;
withCredentials?: boolean;
openFileDialogOnClick?: boolean;
locale?: UploadLocale;
id?: string;
previewFile?: PreviewFileHandler;
transformFile?: TransformFileHandler;
}
export interface UploadState {
fileList: UploadFile[];
dragState: string;
}
export interface UploadListProps {
listType?: UploadListType;
onPreview?: (file: UploadFile) => void;
onRemove?: (file: UploadFile) => void | boolean;
items?: Array<UploadFile>;
progressAttr?: Object;
prefixCls?: string;
showRemoveIcon?: boolean;
showPreviewIcon?: boolean;
locale: UploadLocale;
previewFile?: PreviewFileHandler;
}