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


PHP File::getMimeType方法代碼示例

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


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

示例1: storageIsNotAskedForMimeTypeForPersistedRecord

 /**
  * This test accounts for an inconsistency in the Storage–Driver interface of FAL: The driver returns the MIME
  * type in a field "mimetype", while the file object and the database table use mime_type.
  * The test is placed in the test case for AbstractFile because the broken functionality resides there, though
  * it is only triggered when constructing a File instance with an index record.
  *
  * @test
  */
 public function storageIsNotAskedForMimeTypeForPersistedRecord()
 {
     $mockedStorage = $this->getMockBuilder('TYPO3\\CMS\\Core\\Resource\\ResourceStorage')->disableOriginalConstructor()->getMock();
     $mockedStorage->expects($this->never())->method('getFileInfoByIdentifier')->with('/foo', 'mimetype');
     $subject = new File(array('identifier' => '/foo', 'mime_type' => 'my/mime-type'), $mockedStorage);
     $this->assertEquals('my/mime-type', $subject->getMimeType());
 }
開發者ID:khanhdeux,項目名稱:typo3test,代碼行數:15,代碼來源:AbstractFileTest.php

示例2: renderFileInformationContent

 /**
  * Renders a HTML Block with file information
  *
  * @param File $file
  * @return string
  */
 protected function renderFileInformationContent(File $file = null)
 {
     /** @var LanguageService $lang */
     $lang = $GLOBALS['LANG'];
     if ($file !== null) {
         $processedFile = $file->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, ['width' => 150, 'height' => 150]);
         $previewImage = $processedFile->getPublicUrl(true);
         $content = '';
         if ($file->isMissing()) {
             $content .= '<span class="label label-danger label-space-right">' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:warning.file_missing')) . '</span>';
         }
         if ($previewImage) {
             $content .= '<img src="' . htmlspecialchars($previewImage) . '" ' . 'width="' . $processedFile->getProperty('width') . '" ' . 'height="' . $processedFile->getProperty('height') . '" ' . 'alt="" class="t3-tceforms-sysfile-imagepreview" />';
         }
         $content .= '<strong>' . htmlspecialchars($file->getName()) . '</strong>';
         $content .= ' (' . htmlspecialchars(GeneralUtility::formatSize($file->getSize())) . 'bytes)<br />';
         $content .= BackendUtility::getProcessedValue('sys_file', 'type', $file->getType()) . ' (' . $file->getMimeType() . ')<br />';
         $content .= htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_misc.xlf:fileMetaDataLocation')) . ': ';
         $content .= htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '<br />';
         $content .= '<br />';
     } else {
         $content = '<h2>' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_misc.xlf:fileMetaErrorInvalidRecord')) . '</h2>';
     }
     return $content;
 }
開發者ID:,項目名稱:,代碼行數:31,代碼來源:

示例3: storageIsNotAskedForMimeTypeForPersistedRecord

 /**
  * This test accounts for an inconsistency in the Storage–Driver interface of FAL: The driver returns the MIME
  * type in a field "mimetype", while the file object and the database table use mime_type.
  * The test is placed in the test case for AbstractFile because the broken functionality resides there, though
  * it is only triggered when constructing a File instance with an index record.
  *
  * @test
  */
 public function storageIsNotAskedForMimeTypeForPersistedRecord()
 {
     /** @var ResourceStorage|\PHPUnit_Framework_MockObject_MockObject $mockedStorage */
     $mockedStorage = $this->getMockBuilder(ResourceStorage::class)->disableOriginalConstructor()->getMock();
     $mockedStorage->expects($this->never())->method('getFileInfoByIdentifier')->with('/foo', 'mimetype');
     $subject = new File(array('identifier' => '/foo', 'mime_type' => 'my/mime-type'), $mockedStorage);
     $this->assertEquals('my/mime-type', $subject->getMimeType());
 }
開發者ID:rickymathew,項目名稱:TYPO3.CMS,代碼行數:16,代碼來源:AbstractFileTest.php

示例4: getMimeType

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


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