コード例 #1
0
ファイル: FileRepo.php プロジェクト: paladox/mediawiki
 /**
  * Attempt to stream a file with the given virtual URL/storage path
  *
  * @param string $virtualUrl
  * @param array $headers Additional HTTP headers to send on success
  * @param array $optHeaders HTTP request headers (if-modified-since, range, ...)
  * @return Status
  * @since 1.27
  */
 public function streamFileWithStatus($virtualUrl, $headers = [], $optHeaders = [])
 {
     $path = $this->resolveToStoragePath($virtualUrl);
     $params = ['src' => $path, 'headers' => $headers, 'options' => $optHeaders];
     $status = $this->newGood();
     $status->merge($this->backend->streamFile($params));
     return $status;
 }
コード例 #2
0
ファイル: FileBackendTest.php プロジェクト: paladox/mediawiki
 private function doTestStreamFileRange()
 {
     $backendName = $this->backendClass();
     $base = self::baseStorePath();
     $path = "{$base}/unittest-cont1/e/b/z/range_file.txt";
     $content = "0123456789ABCDEF";
     $this->prepare(['dir' => dirname($path)]);
     $status = $this->create(['dst' => $path, 'content' => $content]);
     $this->assertGoodStatus($status, "Creation of file at {$path} succeeded ({$backendName}).");
     static $ranges = ['bytes=0-0' => '0', 'bytes=0-3' => '0123', 'bytes=4-8' => '45678', 'bytes=15-15' => 'F', 'bytes=14-15' => 'EF', 'bytes=-5' => 'BCDEF', 'bytes=-1' => 'F', 'bytes=10-16' => 'ABCDEF', 'bytes=10-99' => 'ABCDEF'];
     foreach ($ranges as $range => $chunk) {
         ob_start();
         $this->backend->streamFile(['src' => $path, 'headless' => 1, 'allowOB' => 1, 'options' => ['range' => $range]]);
         $data = ob_get_contents();
         ob_end_clean();
         $this->assertEquals($chunk, $data, "Correct chunk streamed from '{$path}' for '{$range}'");
     }
 }
コード例 #3
0
ファイル: FileRepo.php プロジェクト: Tjorriemorrie/app
 /**
  * Attempt to stream a file with the given virtual URL/storage path
  *
  * @param $virtualUrl string
  * @param $headers Array Additional HTTP headers to send on success
  * @return bool Success
  */
 public function streamFile($virtualUrl, $headers = array())
 {
     $path = $this->resolveToStoragePath($virtualUrl);
     $params = array('src' => $path, 'headers' => $headers);
     return $this->backend->streamFile($params)->isOK();
 }
コード例 #4
0
ファイル: FileRepo.php プロジェクト: claudinec/galan-wiki
 /**
  * Attempt to stream a file with the given virtual URL/storage path
  *
  * @param string $virtualUrl
  * @param array $headers Additional HTTP headers to send on success
  * @return Status
  * @since 1.27
  */
 public function streamFileWithStatus($virtualUrl, $headers = [])
 {
     $path = $this->resolveToStoragePath($virtualUrl);
     $params = ['src' => $path, 'headers' => $headers];
     return $this->backend->streamFile($params);
 }