Beispiel #1
0
 /**
  * Constructor
  *
  * @param array $image image meta data
  * @param int $statusCode the HTTP status code, defaults to 200
  */
 public function __construct(array $image, $statusCode = Http::STATUS_OK)
 {
     $name = $image['name'];
     $this->preview = $image['preview'];
     $this->setStatus($statusCode);
     $this->addHeader('Content-type', $image['mimetype'] . '; charset=utf-8');
     \OCP\Response::setContentDispositionHeader($name, 'attachment');
 }
Beispiel #2
0
 public function show()
 {
     if ($this->useOriginal) {
         $fp = @$this->view->fopen($this->path, 'rb');
         $mtime = $this->view->filemtime($this->path);
         $size = $this->view->filesize($this->path);
         $mime = $this->view->getMimetype($this->path);
     } else {
         $fp = @fopen($this->path, 'rb');
         $mtime = filemtime($this->path);
         $size = filesize($this->path);
         $mime = \OC_Helper::getMimetype($this->path);
     }
     if ($fp) {
         \OCP\Response::enableCaching();
         \OCP\Response::setLastModifiedHeader($mtime);
         header('Content-Length: ' . $size);
         header('Content-Type: ' . $mime);
         \OCP\Response::setContentDispositionHeader(basename($this->path), 'attachment');
         fpassthru($fp);
     } else {
         \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
     }
 }