3
3
namespace Http \Message \MultipartStream ;
4
4
5
5
/**
6
- * This class helps to find the proper mime types. The source of this file is taken
7
- * from Guzzle.
8
- *
9
- * @author Michael Dowling and contributors to guzzlehttp/psr7
10
6
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
11
7
*/
12
- class MimetypeHelper
8
+ interface MimetypeHelper
13
9
{
14
10
/**
15
11
* Determines the mimetype of a file by looking at its extension.
@@ -18,127 +14,14 @@ class MimetypeHelper
18
14
*
19
15
* @return null|string
20
16
*/
21
- public static function getMimetypeFromFilename ($ filename )
22
- {
23
- return static ::getMimetypeFromExtension (pathinfo ($ filename , PATHINFO_EXTENSION ));
24
- }
17
+ public function getMimetypeFromFilename ($ filename );
25
18
26
19
/**
27
20
* Maps a file extensions to a mimetype.
28
21
*
29
- * @param string $extension The file extension.
22
+ * @param string $extension The file extension
30
23
*
31
24
* @return string|null
32
- *
33
- * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
34
25
*/
35
- public static function getMimetypeFromExtension ($ extension )
36
- {
37
- static $ mimetypes = [
38
- '7z ' => 'application/x-7z-compressed ' ,
39
- 'aac ' => 'audio/x-aac ' ,
40
- 'ai ' => 'application/postscript ' ,
41
- 'aif ' => 'audio/x-aiff ' ,
42
- 'asc ' => 'text/plain ' ,
43
- 'asf ' => 'video/x-ms-asf ' ,
44
- 'atom ' => 'application/atom+xml ' ,
45
- 'avi ' => 'video/x-msvideo ' ,
46
- 'bmp ' => 'image/bmp ' ,
47
- 'bz2 ' => 'application/x-bzip2 ' ,
48
- 'cer ' => 'application/pkix-cert ' ,
49
- 'crl ' => 'application/pkix-crl ' ,
50
- 'crt ' => 'application/x-x509-ca-cert ' ,
51
- 'css ' => 'text/css ' ,
52
- 'csv ' => 'text/csv ' ,
53
- 'cu ' => 'application/cu-seeme ' ,
54
- 'deb ' => 'application/x-debian-package ' ,
55
- 'doc ' => 'application/msword ' ,
56
- 'docx ' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document ' ,
57
- 'dvi ' => 'application/x-dvi ' ,
58
- 'eot ' => 'application/vnd.ms-fontobject ' ,
59
- 'eps ' => 'application/postscript ' ,
60
- 'epub ' => 'application/epub+zip ' ,
61
- 'etx ' => 'text/x-setext ' ,
62
- 'flac ' => 'audio/flac ' ,
63
- 'flv ' => 'video/x-flv ' ,
64
- 'gif ' => 'image/gif ' ,
65
- 'gz ' => 'application/gzip ' ,
66
- 'htm ' => 'text/html ' ,
67
- 'html ' => 'text/html ' ,
68
- 'ico ' => 'image/x-icon ' ,
69
- 'ics ' => 'text/calendar ' ,
70
- 'ini ' => 'text/plain ' ,
71
- 'iso ' => 'application/x-iso9660-image ' ,
72
- 'jar ' => 'application/java-archive ' ,
73
- 'jpe ' => 'image/jpeg ' ,
74
- 'jpeg ' => 'image/jpeg ' ,
75
- 'jpg ' => 'image/jpeg ' ,
76
- 'js ' => 'text/javascript ' ,
77
- 'json ' => 'application/json ' ,
78
- 'latex ' => 'application/x-latex ' ,
79
- 'log ' => 'text/plain ' ,
80
- 'm4a ' => 'audio/mp4 ' ,
81
- 'm4v ' => 'video/mp4 ' ,
82
- 'mid ' => 'audio/midi ' ,
83
- 'midi ' => 'audio/midi ' ,
84
- 'mov ' => 'video/quicktime ' ,
85
- 'mp3 ' => 'audio/mpeg ' ,
86
- 'mp4 ' => 'video/mp4 ' ,
87
- 'mp4a ' => 'audio/mp4 ' ,
88
- 'mp4v ' => 'video/mp4 ' ,
89
- 'mpe ' => 'video/mpeg ' ,
90
- 'mpeg ' => 'video/mpeg ' ,
91
- 'mpg ' => 'video/mpeg ' ,
92
- 'mpg4 ' => 'video/mp4 ' ,
93
- 'oga ' => 'audio/ogg ' ,
94
- 'ogg ' => 'audio/ogg ' ,
95
- 'ogv ' => 'video/ogg ' ,
96
- 'ogx ' => 'application/ogg ' ,
97
- 'pbm ' => 'image/x-portable-bitmap ' ,
98
- 'pdf ' => 'application/pdf ' ,
99
- 'pgm ' => 'image/x-portable-graymap ' ,
100
- 'png ' => 'image/png ' ,
101
- 'pnm ' => 'image/x-portable-anymap ' ,
102
- 'ppm ' => 'image/x-portable-pixmap ' ,
103
- 'ppt ' => 'application/vnd.ms-powerpoint ' ,
104
- 'pptx ' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation ' ,
105
- 'ps ' => 'application/postscript ' ,
106
- 'qt ' => 'video/quicktime ' ,
107
- 'rar ' => 'application/x-rar-compressed ' ,
108
- 'ras ' => 'image/x-cmu-raster ' ,
109
- 'rss ' => 'application/rss+xml ' ,
110
- 'rtf ' => 'application/rtf ' ,
111
- 'sgm ' => 'text/sgml ' ,
112
- 'sgml ' => 'text/sgml ' ,
113
- 'svg ' => 'image/svg+xml ' ,
114
- 'swf ' => 'application/x-shockwave-flash ' ,
115
- 'tar ' => 'application/x-tar ' ,
116
- 'tif ' => 'image/tiff ' ,
117
- 'tiff ' => 'image/tiff ' ,
118
- 'torrent ' => 'application/x-bittorrent ' ,
119
- 'ttf ' => 'application/x-font-ttf ' ,
120
- 'txt ' => 'text/plain ' ,
121
- 'wav ' => 'audio/x-wav ' ,
122
- 'webm ' => 'video/webm ' ,
123
- 'wma ' => 'audio/x-ms-wma ' ,
124
- 'wmv ' => 'video/x-ms-wmv ' ,
125
- 'woff ' => 'application/x-font-woff ' ,
126
- 'wsdl ' => 'application/wsdl+xml ' ,
127
- 'xbm ' => 'image/x-xbitmap ' ,
128
- 'xls ' => 'application/vnd.ms-excel ' ,
129
- 'xlsx ' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ' ,
130
- 'xml ' => 'application/xml ' ,
131
- 'xpm ' => 'image/x-xpixmap ' ,
132
- 'xwd ' => 'image/x-xwindowdump ' ,
133
- 'yaml ' => 'text/yaml ' ,
134
- 'yml ' => 'text/yaml ' ,
135
- 'zip ' => 'application/zip ' ,
136
- ];
137
-
138
- $ extension = strtolower ($ extension );
139
-
140
- return isset ($ mimetypes [$ extension ])
141
- ? $ mimetypes [$ extension ]
142
- : null ;
143
- }
26
+ public function getMimetypeFromExtension ($ extension );
144
27
}
0 commit comments