File Upload Configuration
Used to configure file upload settings, including allowed file types, file size limits, etc. For file upload methods and file deletion methods, please refer to Methods.
Default Configuration
{
file: {
allowedMimeTypes: [],
maxSize: 1024 * 1024 * 100, // 100M
preview: [ // Added in v5.0.0
{ extensions: ['pdf'], url: '{url}' },
{
extensions: ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'],
url: 'https://view.officeapps.live.com/op/embed.aspx?src={{url}}&wdStartOn=1&wdPrint=0&wdEmbedCode=0',
},
],
},
}
Configuration Options
file.allowedMimeTypes
Description: Allowed file types for upload. An empty array means all file types are allowed.
Type: Array
Default Value: []
.
Optional Values:
Valid MIME types.
Additionally, if you want to upload files of the same type, you can use *
to simplify the configuration. For example, to allow all images, you can configure it as ['image/*']
.
file.maxSize
Description: The maximum size of files allowed for upload, in bytes (B).
Type: Number
Default Value: 1024 * 1024 * 100
(100M)
file.preview
Description: Configuration for file preview, including file types and preview links. Note that modifying this value will directly overwrite the default value. If you need to adjust the file preview configuration, modify it based on the default value. Added in v5.0.0
Type: Array
Default Value:
[
{ extensions: ['pdf'], url: '{url}' },
{
extensions: ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'],
url: 'https://view.officeapps.live.com/op/embed.aspx?src={{url}}&wdStartOn=1&wdPrint=0&wdEmbedCode=0',
},
]
Optional Values:
preview[].extensions
: Array of supported file extensions, refer to the default value.preview[].url
: Preview link, which can be a string or an array of strings. Supports{url}
and{{url}}
placeholders, used to replace the uploaded fileβs URL and encode the URL withencodeURIComponent
, respectively.