feat: 上传文件到minio
This commit is contained in:
18
src/utils/get-content-type.ts
Normal file
18
src/utils/get-content-type.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import path from 'path';
|
||||
// 获取文件的 content-type
|
||||
export const getContentType = (filePath: string) => {
|
||||
const extname = path.extname(filePath);
|
||||
const contentType = {
|
||||
'.html': 'text/html',
|
||||
'.js': 'text/javascript',
|
||||
'.css': 'text/css',
|
||||
'.json': 'application/json',
|
||||
'.png': 'image/png',
|
||||
'.jpg': 'image/jpg',
|
||||
'.gif': 'image/gif',
|
||||
'.svg': 'image/svg+xml',
|
||||
'.wav': 'audio/wav',
|
||||
'.mp4': 'video/mp4',
|
||||
};
|
||||
return contentType[extname] || 'application/octet-stream';
|
||||
};
|
||||
Reference in New Issue
Block a user