コード例 #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
ファイル: CakeResponseTest.php プロジェクト: thedrumz/music
 /**
  * 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
ファイル: CsvFileWriter.php プロジェクト: s-nakajima/files
 /**
  * ダウンロード
  *
  * @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
ファイル: ZipDownloader.php プロジェクト: s-nakajima/files
 /**
  * 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;
 }