/** * Extract files from mime multipart file * * @param string $input The file to extract * * @return array The list of extracted files (path / mimetype / filename) */ public function extract($input) { try { $output = self::getTempFilename(); // execute main operation $command = self::$javapath . ' -jar ' . escapeshellarg($this->AS2_DIR_BIN . self::$ssl_adapter) . ' extract' . ' -in ' . escapeshellarg($input) . ' -out ' . escapeshellarg($output); $results = self::exec($command, true); // array returned $files = array(); foreach ($results as $tmp) { $tmp = explode(';', $tmp); if (count($tmp) <= 1) { continue; } if (count($tmp) != 3) { throw new AS2Exception('Unexpected data structure while extracting message.'); } $file = array(); $file['path'] = trim($tmp[0], '"'); $file['mimetype'] = trim($tmp[1], '"'); $file['filename'] = trim($tmp[2], '"'); $files[] = $file; // schedule file deletion Adapter::addTempFileForDelete($file['path']); } return $files; } catch (Exception $e) { throw $e; } }