當前位置: 首頁>>代碼示例>>PHP>>正文


PHP View::readfile方法代碼示例

本文整理匯總了PHP中OC\Files\View::readfile方法的典型用法代碼示例。如果您正苦於以下問題:PHP View::readfile方法的具體用法?PHP View::readfile怎麽用?PHP View::readfile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OC\Files\View的用法示例。


在下文中一共展示了View::readfile方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getSingleFile

 /**
  * @param View $view
  * @param string $name
  * @param string $dir
  * @param boolean $onlyHeader
  */
 private static function getSingleFile($view, $dir, $name, $onlyHeader)
 {
     $filename = $dir . '/' . $name;
     OC_Util::obEnd();
     $view->lockFile($filename, ILockingProvider::LOCK_SHARED);
     if (\OC\Files\Filesystem::isReadable($filename)) {
         self::sendHeaders($filename, $name);
     } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->printPage();
         exit;
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if ($onlyHeader) {
         return;
     }
     $view->readfile($filename);
 }
開發者ID:farukuzun,項目名稱:core-1,代碼行數:27,代碼來源:files.php

示例2: getSingleFile

 /**
  * @param View $view
  * @param string $name
  * @param string $dir
  * @param array $params ; 'head' boolean to only send header of the request ; 'range' http range header
  */
 private static function getSingleFile($view, $dir, $name, $params)
 {
     $filename = $dir . '/' . $name;
     OC_Util::obEnd();
     $view->lockFile($filename, ILockingProvider::LOCK_SHARED);
     $rangeArray = array();
     if (isset($params['range']) && substr($params['range'], 0, 6) === 'bytes=') {
         $rangeArray = self::parseHttpRangeHeader(substr($params['range'], 6), \OC\Files\Filesystem::filesize($filename));
     }
     if (\OC\Files\Filesystem::isReadable($filename)) {
         self::sendHeaders($filename, $name, $rangeArray);
     } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->printPage();
         exit;
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if (isset($params['head']) && $params['head']) {
         return;
     }
     if (!empty($rangeArray)) {
         try {
             if (count($rangeArray) == 1) {
                 $view->readfilePart($filename, $rangeArray[0]['from'], $rangeArray[0]['to']);
             } else {
                 // check if file is seekable (if not throw UnseekableException)
                 // we have to check it before body contents
                 $view->readfilePart($filename, $rangeArray[0]['size'], $rangeArray[0]['size']);
                 $type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
                 foreach ($rangeArray as $range) {
                     echo "\r\n--" . self::getBoundary() . "\r\n" . "Content-type: " . $type . "\r\n" . "Content-range: bytes " . $range['from'] . "-" . $range['to'] . "/" . $range['size'] . "\r\n\r\n";
                     $view->readfilePart($filename, $range['from'], $range['to']);
                 }
                 echo "\r\n--" . self::getBoundary() . "--\r\n";
             }
         } catch (\OCP\Files\UnseekableException $ex) {
             // file is unseekable
             header_remove('Accept-Ranges');
             header_remove('Content-Range');
             header("HTTP/1.1 200 OK");
             self::sendHeaders($filename, $name, array());
             $view->readfile($filename);
         }
     } else {
         $view->readfile($filename);
     }
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:56,代碼來源:files.php

示例3: readfile

 public static function readfile($path)
 {
     return self::$defaultInstance->readfile($path);
 }
開發者ID:stweil,項目名稱:owncloud-core,代碼行數:4,代碼來源:Filesystem.php

示例4: getSingleFile

 /**
  * @param View $view
  * @param string $name
  */
 private static function getSingleFile($view, $dir, $name, $onlyHeader)
 {
     $filename = $dir . '/' . $name;
     OC_Util::obEnd();
     $view->lockFile($filename, ILockingProvider::LOCK_SHARED);
     if (\OC\Files\Filesystem::isReadable($filename)) {
         self::sendHeaders($filename, $name);
     } elseif (!\OC\Files\Filesystem::file_exists($filename)) {
         header("HTTP/1.0 404 Not Found");
         $tmpl = new OC_Template('', '404', 'guest');
         $tmpl->printPage();
         exit;
     } else {
         header("HTTP/1.0 403 Forbidden");
         die('403 Forbidden');
     }
     if ($onlyHeader) {
         return;
     }
     $type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
     $pos = strpos(strtolower($type), "video");
     if ($pos != -1) {
         $view->streamVideoFile($filename);
     } else {
         $view->readfile($filename);
     }
 }
開發者ID:hassanhawilo,項目名稱:core,代碼行數:31,代碼來源:files.php


注:本文中的OC\Files\View::readfile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。