为了保证文件上传的安全,框架限制了支持的的文件格式,框架默认支持白名单如下:
// images '.jpg', '.jpeg', // image/jpeg '.png', // image/png, image/x-png '.gif', // image/gif '.bmp', // image/bmp '.wbmp', // image/vnd.wap.wbmp '.webp', '.tif', '.psd', // text '.svg', '.js', '.jsx', '.json', '.css', '.less', '.html', '.htm', '.xml', // tar '.zip', '.gz', '.tgz', '.gzip', // video '.mp3', '.mp4', '.avi',
用户可以通过在 config/config.default.js
中配置来新增支持的文件扩展名,或者重写整个白名单
- 新增支持的文件扩展名
module.exports = {
|
- 覆盖整个白名单
module.exports = {
|
注意:当重写了 whitelist 时,fileExtensions 不生效。