DocumentionConfigurationFile Upload

File Upload Configuration

This section is used to configure file upload settings, including allowed file types and file size limits. For methods of file uploading and file deletion, please refer to the Methods.

Default Configuration

{
  file: {
    allowedMimeTypes: [],
    maxSize: 1024 * 1024 * 100, // 100MB
    preview: [ // New 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 Item Descriptions

file.allowedMimeTypes

Description: The allowed file types for upload. An empty array indicates that all file types are allowed.

Type: Array

Default: [].

Options:

Valid MIME type values.

Additionally, to upload files of the same type, you can use the * wildcard for simplified configuration. For example, to allow the upload of all image files, it can be configured as ['image/*'].

file.maxSize

Description: The maximum size allowed for uploaded files, in bytes (B).

Type: Number.

Default: 1024 * 1024 * 100 (100M)

file.preview

Description: Preview file configuration, including file type and preview link, note that modifying this value will directly override the default value, if you need to adjust the preview file configuration, please make changes based on the default value. New in v5.0.0

Type: Array

Default:

[
  { 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: The supported file suffix array, refer to the default value.
  • preview[].url: The preview link, which can be a string or an array of strings, supporting {url} and {{url}} placeholders for replacing the uploaded file URL and performing encodeURIComponent encoding, respectively.