本文整理汇总了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()];
}
示例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;
}
示例3: getContents
/**
* Get the contents of this file
*
* @return string File contents
*/
public function getContents()
{
return $this->originalFile->getContents();
}
示例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;
}
示例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;
}