示例#1
0
 protected function _deliverMedia(CakeResponse $response, $mediaFile, $mediaInfo)
 {
     $response->sharable(true, 2592000);
     //$response->mustRevalidate(true);
     $response->expires('+30 days');
     $modTime = filemtime($mediaFile);
     $response->modified($modTime);
     $response->etag(md5($mediaFile . $modTime));
     //$response->header("Pragma", "cache");
     $response->type($mediaInfo['ext']);
     $response->file($mediaFile);
     $response->send();
 }
示例#2
0
 /**
  * testFileNotFound
  *
  * @expectedException NotFoundException
  * @return void
  */
 public function testFileNotFound()
 {
     $response = new CakeResponse();
     $response->file('/some/missing/folder/file.jpg');
 }
示例#3
0
 /**
  * test file with ..
  *
  * @expectedException NotFoundException
  * @return void
  */
 public function testFileWithPathTraversal()
 {
     $response = new CakeResponse();
     $response->file('my/../cat.gif');
 }
示例#4
0
 /**
  * Although unlikely, a file may contain dots in its filename.
  * This should be allowed, as long as the dots doesn't specify a path (../ or ..\)
  *
  * @expectedException NotFoundException
  * @execptedExceptionMessageRegExp #The requested file .+my/Some..cat.gif was not found or not readable#
  * @return void
  */
 public function testFileWithDotsInFilename()
 {
     $response = new CakeResponse();
     $response->file('my/Some..cat.gif');
 }
示例#5
0
 /**
  * ダウンロード
  *
  * @param string $filename ダウンロード時のファイル名
  * @return CakeResponse
  */
 public function download($filename)
 {
     $response = new CakeResponse();
     $response->type('text/csv');
     $response->file($this->path, ['name' => $filename, 'download' => 'true']);
     return $response;
 }
示例#6
0
 /**
  * Download
  *
  * @param string $filename download時のファイル名
  * @return CakeResponse ダウンロードレスポンス
  */
 public function download($filename)
 {
     // closeされてなかったらcloseする
     if ($this->_open) {
         $this->close();
     }
     $response = new CakeResponse();
     $response->type('application/zip');
     $response->file($this->path, ['name' => $filename, 'download' => 'true']);
     return $response;
 }