We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currently only returning 500 Even if I try to exit with error code the framework seems to be catching me first.
public function saveNewFile($sourceFile, $newFileName, $options) { $newFilePath = TMP_DIR . $newFileName; try { $tmpFile = $this->saveToTemporaryFile($sourceFile); } catch (Exception $e) { http_response_code($e->getCode()); exit($e->getMessage()); } $commandStr = $this->generateCmdString($newFilePath, $tmpFile, $options); exec($commandStr, $output, $code); if (count($output) === 0) { $output = $code; } else { $output = implode(PHP_EOL, $output); } if ($code !== 0) { throw new \Exception($output . ' Command line: ' . $commandStr); } $this->filesystem->write($newFileName, stream_get_contents(fopen($newFilePath, 'r'))); unlink($tmpFile); unlink($newFilePath); }
and then
public function saveToTemporaryFile($fileUrl) { //check restricted_domains is enabled if ($this->params['restricted_domains'] && is_array($this->params['whitelist_domains']) && !in_array(parse_url($fileUrl, PHP_URL_HOST), $this->params['whitelist_domains']) ) { throw new \Exception('Restricted domains enabled, the domain your fetching from is not allowed: ' . parse_url($fileUrl, PHP_URL_HOST), 403); } if (!$resource = @fopen($fileUrl, "r")) { throw new \Exception('Error occured while trying to read the file Url : ' . $fileUrl, 400); } $content = ""; while ($line = fread($resource, 1024)) { $content .= $line; } $tmpFile = TMP_DIR . uniqid("", true); file_put_contents($tmpFile, $content); return $tmpFile; }
but it doesn't work
The text was updated successfully, but these errors were encountered:
You missing \ in front of Exception, catch (\Exception $e) {
catch (\Exception $e) {
Sorry, something went wrong.
Merge pull request #6 from sadok-f/master
86e9465
pull from upstram
No branches or pull requests
Currently only returning 500
Even if I try to exit with error code the framework seems to be catching me first.
and then
but it doesn't work
The text was updated successfully, but these errors were encountered: