当前位置: 首页>>代码示例>>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;未经允许,请勿转载。