Example #1
0
 /**
  * @param File $file
  * @param mixed $handler
  * @param array $params
  * @param string $prefix
  * @return boolean New file exists ?
  */
 public function process($file, $handler, array $params = array(), $prefix = null)
 {
     $path = $file->getFsPath($prefix);
     try {
         // create temporary file
         $tmp = tmpfile();
         // copy file stream contents
         if (stream_copy_to_stream($file->readStream(), $tmp)) {
             $meta = stream_get_meta_data($tmp);
             $params[] = $meta['uri'];
             $params[] = $file;
             $this->write($path, call_user_func_array($handler, $params));
         }
         fclose($tmp);
     } catch (\Exception $e) {
     }
     return $this->has($path);
 }