useFileList

Source
import { useFileList } from "@prestojs/ui-antd";
useFileList(value,options)

Given a value that could either be a URL, a File or an array of either return an array of UploadFile to be used with the antd Upload component. A function updateFileStatus is returned to allow updating the progress and final status of a file.

ParameterTypeDescription
*valueFileLike|FileLike[]|null|undefined

The value to convert. This would typically come from the form state.

options.getThumbUrl
Function

When previewImage is true this function will be called to generate a URL to use as the thumbnail for an image. It can either return a Promise that resolves to a string/false or return string/false directly

If not specified or getThumbUrl returns false then the underlying File will be read and a thumbnail generated automatically.

options.previewImageboolean

If true the thumbUrl property will be set for each UploadFile

UseFileListReturn
KeyTypeDescription
fileListUploadFile[]

List of objects that can be passed to the fileList prop on Upload

updateFileStatus
Function

Should be called from the onChange prop on Upload and passed the changed file. This is used to update the progress on overall status of the file. Only applicable when an upload is occurring immediately (eg. when you pass customRequest) instead of as part of the final form submission.