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


PHP File::getContents方法代碼示例

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


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

示例1: getOnlineMediaId

 /**
  * Get Online Media item id
  *
  * @param File $file
  * @return string
  */
 public function getOnlineMediaId(File $file)
 {
     if (!isset($this->onlineMediaIdCache[$file->getUid()])) {
         // By definition these files only contain the ID of the remote media source
         $this->onlineMediaIdCache[$file->getUid()] = trim($file->getContents());
     }
     return $this->onlineMediaIdCache[$file->getUid()];
 }
開發者ID:vip3out,項目名稱:TYPO3.CMS,代碼行數:14,代碼來源:AbstractOnlineMediaHelper.php

示例2: export_addSysFile

 /**
  * Adds a files content from a sys file record to the export memory
  *
  * @param File $file
  * @return void
  */
 public function export_addSysFile(File $file)
 {
     if ($file->getProperty('size') >= $this->maxFileSize) {
         $this->error('File ' . $file->getPublicUrl() . ' was larger (' . GeneralUtility::formatSize($file->getProperty('size')) . ') than the maxFileSize (' . GeneralUtility::formatSize($this->maxFileSize) . ')! Skipping.');
         return;
     }
     $fileContent = '';
     try {
         if (!$this->saveFilesOutsideExportFile) {
             $fileContent = $file->getContents();
         } else {
             $file->checkActionPermission('read');
         }
     } catch (\Exception $e) {
         $this->error('Error when trying to add file ' . $file->getCombinedIdentifier() . ': ' . $e->getMessage());
         return;
     }
     $fileUid = $file->getUid();
     $fileInfo = $file->getStorage()->getFileInfo($file);
     // we sadly have to cast it to string here, because the size property is also returning a string
     $fileSize = (string) $fileInfo['size'];
     if ($fileSize !== $file->getProperty('size')) {
         $this->error('File size of ' . $file->getCombinedIdentifier() . ' is not up-to-date in index! File added with current size.');
         $this->dat['records']['sys_file:' . $fileUid]['data']['size'] = $fileSize;
     }
     $fileSha1 = $file->getStorage()->hashFile($file, 'sha1');
     if ($fileSha1 !== $file->getProperty('sha1')) {
         $this->error('File sha1 hash of ' . $file->getCombinedIdentifier() . ' is not up-to-date in index! File added on current sha1.');
         $this->dat['records']['sys_file:' . $fileUid]['data']['sha1'] = $fileSha1;
     }
     $fileRec = array();
     $fileRec['filesize'] = $fileSize;
     $fileRec['filename'] = $file->getProperty('name');
     $fileRec['filemtime'] = $file->getProperty('modification_date');
     // build unique id based on the storage and the file identifier
     $fileId = md5($file->getStorage()->getUid() . ':' . $file->getProperty('identifier_hash'));
     // Setting this data in the header
     $this->dat['header']['files_fal'][$fileId] = $fileRec;
     if (!$this->saveFilesOutsideExportFile) {
         // ... and finally add the heavy stuff:
         $fileRec['content'] = $fileContent;
     } else {
         GeneralUtility::upload_copy_move($file->getForLocalProcessing(false), $this->getTemporaryFilesPathForExport() . $file->getProperty('sha1'));
     }
     $fileRec['content_sha1'] = $fileSha1;
     $this->dat['files_fal'][$fileId] = $fileRec;
 }
開發者ID:franzholz,項目名稱:TYPO3.CMS,代碼行數:53,代碼來源:ImportExport.php

示例3: getContents

 /**
  * Get the contents of this file
  *
  * @return string File contents
  */
 public function getContents()
 {
     return $this->originalFile->getContents();
 }
開發者ID:,項目名稱:,代碼行數:9,代碼來源:

示例4: export_addSysFile

 /**
  * Adds a files content from a sys file record to the export memory
  *
  * @param \TYPO3\CMS\Core\Resource\File $file
  * @return void
  */
 public function export_addSysFile(\TYPO3\CMS\Core\Resource\File $file)
 {
     if ($file->getProperty('size') >= $this->maxFileSize) {
         $this->error('File ' . $file->getPublicUrl() . ' was larger (' . GeneralUtility::formatSize($file->getProperty('size')) . ') than the maxFileSize (' . GeneralUtility::formatSize($this->maxFileSize) . ')! Skipping.');
         return;
     }
     try {
         $fileContent = $file->getContents();
     } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
         $this->error('File ' . $file->getPublicUrl() . ': ' . $e->getMessage());
         return;
     } catch (\TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException $e) {
         $this->error('File ' . $file->getPublicUrl() . ': ' . $e->getMessage());
         return;
     }
     $fileUid = $file->getUid();
     $fileInfo = $file->getStorage()->getFileInfo($file);
     // we sadly have to cast it to string here, because the size property is also returning a string
     $fileSize = (string) $fileInfo['size'];
     if ($fileSize !== $file->getProperty('size')) {
         $this->error('File size of ' . $file->getCombinedIdentifier() . ' is not up-to-date in index! File added with current size.');
         $this->dat['records']['sys_file:' . $fileUid]['data']['size'] = $fileSize;
     }
     $fileSha1 = $file->getStorage()->hashFile($file, 'sha1');
     if ($fileSha1 !== $file->getProperty('sha1')) {
         $this->error('File sha1 hash of ' . $file->getCombinedIdentifier() . ' is not up-to-date in index! File added on current sha1.');
         $this->dat['records']['sys_file:' . $fileUid]['data']['sha1'] = $fileSha1;
     }
     $fileRec = array();
     $fileRec['filesize'] = $fileSize;
     $fileRec['filename'] = $file->getProperty('name');
     $fileRec['filemtime'] = $file->getProperty('modification_date');
     // build unique id based on the storage and the file identifier
     $fileId = md5($file->getStorage()->getUid() . ':' . $file->getProperty('identifier_hash'));
     // Setting this data in the header
     $this->dat['header']['files_fal'][$fileId] = $fileRec;
     // ... and finally add the heavy stuff:
     $fileRec['content'] = $fileContent;
     $fileRec['content_sha1'] = $fileSha1;
     $this->dat['files_fal'][$fileId] = $fileRec;
 }
開發者ID:samuweiss,項目名稱:TYPO3-Site,代碼行數:47,代碼來源:ImportExport.php

示例5: extractMetaData

 /**
  * Takes a file reference and extracts its meta data.
  *
  * @param \TYPO3\CMS\Core\Resource\File $file
  * @return array
  */
 public function extractMetaData(File $file)
 {
     $headers = array(TYPO3_user_agent, 'Accept: application/json', 'Content-Type: application/octet-stream', 'Connection: close');
     $context = stream_context_create(array('http' => array('protocol_version' => 1.1, 'method' => 'PUT', 'header' => implode(CRLF, $headers), 'content' => $file->getContents())));
     $rawResponse = file_get_contents($this->tikaUrl . '/meta', FALSE, $context);
     $response = (array) json_decode($rawResponse);
     return $response;
 }
開發者ID:AndreasA,項目名稱:ext-tika,代碼行數:14,代碼來源:ServerService.php


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