protected function action() { $headers = ['Content-Type' => $this->resourceDO->getMimeType()]; $filePath = $this->resourceDO->getFilePath(); $fileExists = is_file($filePath); $recreate = PrepareResourceMiddlewareAbstract::getParamFromRequest(static::RECREATE_COMMAND, $this->request); $uri = PrepareResourceMiddlewareAbstract::getParamFromRequest(static::URI_COMMAND, $this->request); $recreate = $fileExists && $recreate; $this->resourceDO->setNew(!$fileExists); if (!$fileExists || $recreate) { $this->resourceDO->setRecreate($recreate); $upload = $this->upload(); // Upload must be with high priority if ($upload) { /** @see \Zend\Diactoros\Response::$phrases */ return new FileUploadedResponse($upload, 201, $headers); } elseif ($uri) { $upload = $this->download($this->resourceDO, $uri); /** @see \Zend\Diactoros\Response::$phrases */ return new FileUploadedResponse($upload, 201, $headers); } else { $body = $this->generate($this->resourceDO); /** @see \Zend\Diactoros\Response::$phrases */ return new FileContentResponse($body, 201, $headers); } } /** @see \Zend\Diactoros\Response::$phrases */ return new EmptyResponse(304, $headers); }
protected function action() { $headers = ['Content-Type' => $this->resourceDO->getMimeType()]; $filePath = $this->resourceDO->getFilePath(); $filename = $this->resourceDO->getName() . '.' . $this->resourceDO->getType(); if ($this->filesystem->has($filePath)) { return $this->XAccelRedirect(realpath($filePath), $filename, false); } /** @see \Zend\Diactoros\Response::$phrases */ return new EmptyResponse(404, $headers); }
protected function action() { $headers = ['Content-Type' => $this->resourceDO->getMimeType()]; $destroy = PrepareResourceMiddlewareAbstract::getParamFromRequest('destroy', $this->request); if ($destroy) { $command = new DestroyResourceCommand($this->resourceDO, $this->filesystem); $command(); } else { $command = new DeleteSafetyResourceCommand($this->resourceDO, $this->filesystem); $command(); } /** @see \Zend\Diactoros\Response::$phrases */ return new EmptyResponse(204, $headers); }