22
33namespace Flow ;
44
5+
56class File
67{
78 /**
@@ -24,7 +25,7 @@ class File
2425 /**
2526 * Constructor
2627 *
27- * @param ConfigInterface $config
28+ * @param ConfigInterface $config
2829 * @param RequestInterface $request
2930 */
3031 public function __construct (ConfigInterface $ config , RequestInterface $ request = null )
@@ -58,7 +59,7 @@ public function getIdentifier()
5859 */
5960 public function getChunkPath ($ index )
6061 {
61- return $ this ->config ->getTempDir (). DIRECTORY_SEPARATOR . $ this ->identifier . '_ ' . $ index ;
62+ return $ this ->config ->getTempDir () . DIRECTORY_SEPARATOR . $ this ->identifier . '_ ' . $ index ;
6263 }
6364
6465 /**
@@ -148,7 +149,7 @@ public function save($destination)
148149 {
149150 $ fh = fopen ($ destination , 'wb ' );
150151 if (!$ fh ) {
151- throw new FileOpenException ('failed to open destination file: ' . $ destination );
152+ throw new FileOpenException ('failed to open destination file: ' . $ destination );
152153 }
153154
154155 if (!flock ($ fh , LOCK_EX | LOCK_NB , $ blocked )) {
@@ -161,7 +162,7 @@ public function save($destination)
161162 }
162163 // @codeCoverageIgnoreEnd
163164
164- throw new FileLockException ('failed to lock file: ' . $ destination );
165+ throw new FileLockException ('failed to lock file: ' . $ destination );
165166 }
166167
167168 $ totalChunks = $ this ->request ->getTotalChunks ();
@@ -174,7 +175,7 @@ public function save($destination)
174175 $ chunk = fopen ($ file , "rb " );
175176
176177 if (!$ chunk ) {
177- throw new FileOpenException ('failed to open chunk: ' . $ file );
178+ throw new FileOpenException ('failed to open chunk: ' . $ file );
178179 }
179180
180181 if ($ preProcessChunk !== null ) {
@@ -230,4 +231,28 @@ public function _move_uploaded_file($filePath, $destinationPath)
230231 {
231232 return move_uploaded_file ($ filePath , $ destinationPath );
232233 }
234+
235+
236+ /**
237+ * Check Mime Type
238+ */
239+ public function checkMime ($ acceptMimes )
240+ {
241+ $ fileMime = $ this ->request ->getFileType ();
242+
243+ foreach ($ acceptMimes as $ acceptMime ) {
244+ if ($ fileMime === $ acceptMime ) {
245+ return true ;
246+ }
247+ }
248+ return false ;
249+ }
250+
251+ /**
252+ * Get Mime Type
253+ */
254+ public function getFileType ()
255+ {
256+ return $ this ->request ->getFileType ();
257+ }
233258}
0 commit comments