Types
API reference docs for all the important types related to files UI components.
ExtFile
Data estructure that "extends" the File Object. This object is designed to allow the information exchange between components.
Name | Type | Description |
---|---|---|
id | string | number | The identifier of the file |
file | File | The file object obtained from client drop or selection |
name | string | The name of the file |
type | string | The file mime type. |
size | number | The size of the file in bytes. |
valid | boolean | If present, it will show a valid or rejected message ("valid", "denied"). By default valid is undefined . |
errors | string[] | The list of errors according to the validation criteria or the result of the given custom validation function. |
uploadStatus | The current upload status. (e.g. "uploading"). | |
uploadMessage | string | A message that shows the result of the upload process. |
imageUrl | string | A string representation or web url of the image that will be set to the "src" prop of an <img/> tag. If given, the component will use this image source instead of reading the image file. |
downloadUrl | string | The url to be used to perform a GET request in order to download the file. If defined, the download icon will be shown. |
progress | number | The current percentage of upload progress. This value will have a higher priority over the upload progress value calculated inside the component. |
extraUploadData | Record<string, any> | The additional data that will be sent to the server when files are uploaded individually |
extraData | Object | Any kind of extra data that could be needed. |
serverResponse | The upload response from server. | |
xhr | XMLHttpRequest | A reference to the XHR object that allows the upload, progress and abort events. |
ValidateFileResponse
Response convention for file validation
Name | Type | Description |
---|---|---|
valid | boolean | If true, that means that the File is valid |
errors | string[] | The list of errors associated with an specific file. |
UploadConfig
Configuration needed for performing the upload process
Name | Type | Default | Description |
---|---|---|---|
url | string | The url endpoint to upload the file. e.g. "https://www.myasomwbackend/uploads/file". | |
method | "POST" | "PUT" | "PATCH" | "POST" | Request headers for http request. |
uploadLabel | string | "file" | The label to use in the request. On the server this must be the label to get the file. |
cleanOnUpload | boolean | Flag for indicating whther to remove the non-valid files before starting the upload process. This flag is valid only if validation is enable. | |
autoUpload | boolean | If true, onDrop event or file selection not only will make Dropzone to return the list of files, but also it will start the upload stage for the files if at least url was set By default is false | |
preparingTime | number | The time that will last the "preparing" stage By default is 1500 miliseconds = 1.5 seconds. | |
uploadingMessage | string | A message to show in the footer when the uploading process takes place. |
HeaderConfig
Advanced configuration for dropzone header
Name | Type | Default | Description |
---|---|---|---|
style | React.CSSProperties | The in-line style object applied to the main container. | |
className | string | The classname to override the css styles in .css or .sass file instead of using in-line styles. Classname is applied to the main container. | |
resetStyles | boolean | If true, the given class name and style properties will replace the default ones instead of overriding them. | |
deleteFiles | boolean | true | If true, the delete icon will be shown. |
cleanFiles | boolean | true | If true, the clean icon will be shown. |
uploadFiles | boolean | true | If true, the upload icon will be shown. |
uploadingIcon | boolean | true | If true, the upload in progress icon will be shown during the upload process. |
maxFileSize | boolean | true | If true, the upload in progress icon will be shown during the upload process. |
validFilesCount | boolean | true | If true, the current count of alid files will be shown. |
customHeader | JSX.Element | A custom header to replace the default one. If given, the rest of the props are ignored |
ServerResponse
Convention for server response
Name | Type | Description |
---|---|---|
success | boolean | If true, it means that the request was successful. |
message | string | A message that describes the result of the request. |
payload | Object | The response of the server. |
UPLOADSTATUS
export type UPLOADSTATUS = "preparing" | "aborted" | "uploading" | "success" | "error";
FilesUIConfig
Global configuration for Files UI components
export type FilesUIConfig = { // If true, dark mode colors are used in FileMosaic and FIleCard components. darkMode?: boolean; // Set of icons to override the existing ones icons?: IconsConfig; // The language in which text labels are shown. localization?: Localization;}
IconsSet
Data type that keeps track of all keys of addmited mime types.
export type IconsSet = { aac?: string; accdb?: string; abw?: string; arc?: string; avi?: string; azw?: string; octet?: string; bmp?: string; bz?: string; bz2?: string; cda?: string; csh?: string; css?: string; csv?: string; docx?: string; drawio?: string; eot?: string; epub?: string; gzip?: string; gif?: string; html?: string; icalendar?: string; jar?: string; jpeg?: string; javascript?: string; json?: string; jsonld?: string; midi?: string; mp3?: string; mp4?: string; mpeg?: string; mpkg?: string; mp2t?: string; odp?: string; ods?: string; odt?: string; oga?: string; ogv?: string; ogx?: string; opus?: string; otf?: string; png?: string; pdf?: string; php?: string; pptx?: string; psd?: string; rar?: string; rtf?: string; sass?: string; sh?: string; swf?: string; tar?: string; tiff?: string; ttf?: string; typescript?: string; text?: string; vsd?: string; wav?: string; weba?: string; webm?: string; webp?: string; woff?: string; wma?: string; wmv?: string; xhtml?: string; xlsx?: string; xml?: string; xul?: string; zip?: string; sevenzip?: string; python?: string; java?: string; react?: string; vue?: string; //fallback when file type is not here fallBack?: string;}