Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function setPath($path)
 {
     // Create full path
     $path = $this->cannonicalizePath($path);
     $this->path = $path;
     $this->filename = basename($path);
     $this->mimetype = Files\MimeMapper::getMimeFromFilename($this->filename);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Sends response to output.
  *
  * @param Http\IRequest $httpRequest
  * @param Http\IResponse $httpResponse
  */
 public function send(Http\IRequest $httpRequest, Http\IResponse $httpResponse)
 {
     $httpResponse->setExpiration(Http\IResponse::PERMANENT);
     if (($inm = $httpRequest->getHeader('if-none-match')) && $inm == $this->etag) {
         $httpResponse->setCode(Http\IResponse::S304_NOT_MODIFIED);
         return;
     }
     $httpResponse->setContentType(AssetsLoader\Files\MimeMapper::getMimeFromFilename($this->filePath));
     $httpResponse->setHeader('Content-Transfer-Encoding', 'binary');
     $httpResponse->setHeader('Content-Length', filesize($this->filePath));
     $httpResponse->setHeader('Content-Disposition', 'attachment; filename="' . basename($this->filePath) . '"');
     $httpResponse->setHeader('Access-Control-Allow-Origin', '*');
     // Read the file
     readfile($this->filePath);
 }