File tree 1 file changed +0
-51
lines changed
web/apps/web/src/services/common
1 file changed +0
-51
lines changed Original file line number Diff line number Diff line change @@ -6,61 +6,10 @@ export interface UploadResponse {
6
6
url : string ;
7
7
}
8
8
9
- const ALLOWED_FILE_TYPES = [
10
- // 图片类型
11
- 'image/jpeg' ,
12
- 'image/png' ,
13
- 'image/gif' ,
14
- 'image/webp' ,
15
- 'image/svg+xml' ,
16
- 'image/bmp' ,
17
- 'image/tiff' ,
18
- // 音频类型
19
- 'audio/mpeg' ,
20
- 'audio/ogg' ,
21
- 'audio/wav' ,
22
- 'audio/webm' ,
23
- 'audio/aac' ,
24
- 'audio/flac' ,
25
- 'audio/mp4' ,
26
- // 视频类型
27
- 'video/mp4' ,
28
- 'video/webm' ,
29
- 'video/ogg' ,
30
- 'video/quicktime' ,
31
- 'video/x-msvideo' ,
32
- 'video/x-matroska' ,
33
- // 文档类型
34
- 'application/pdf' ,
35
- 'application/msword' ,
36
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ,
37
- 'application/vnd.ms-excel' ,
38
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ,
39
- 'application/vnd.ms-powerpoint' ,
40
- 'application/vnd.openxmlformats-officedocument.presentationml.presentation' ,
41
- // 其他常见文件类型
42
- 'text/plain' ,
43
- 'text/html' ,
44
- 'text/csv' ,
45
- 'application/json' ,
46
- 'application/zip' ,
47
- 'application/x-rar-compressed' ,
48
- ] ;
49
-
50
9
export async function upload (
51
10
file : File ,
52
11
name ?: string ,
53
12
) : Promise < UploadResponse > {
54
- if ( ! ALLOWED_FILE_TYPES . includes ( file . type ) ) {
55
- toast . error ( 'Not supported file type' , {
56
- position : 'top-center' ,
57
- autoClose : 2000 ,
58
- hideProgressBar : true ,
59
- pauseOnHover : true ,
60
- closeButton : false ,
61
- } ) ;
62
- return { url : '' } ;
63
- }
64
13
const formData = new FormData ( ) ;
65
14
formData . append ( 'file' , file , name || file . name ) ;
66
15
const response = await APIFetch . post < { file_path : string } > ( '/api/upload' , {
You can’t perform that action at this time.
0 commit comments