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


PHP Files::getMimeType方法代碼示例

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


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

示例1: show

 /**
  * Get the template for a specific activity-event in the activities
  *
  * @param array $activity An array with all the activity data in it
  * @return string
  */
 public function show($activity)
 {
     $tmpl = new Template('activity', 'stream.item');
     $tmpl->assign('formattedDate', $this->dateTimeFormatter->formatDateTime($activity['timestamp']));
     $tmpl->assign('formattedTimestamp', Template::relative_modified_date($activity['timestamp']));
     if (strpos($activity['subjectformatted']['markup']['trimmed'], '<a ') !== false) {
         // We do not link the subject as we create links for the parameters instead
         $activity['link'] = '';
     }
     $tmpl->assign('event', $activity);
     if ($activity['file']) {
         $this->view->chroot('/' . $activity['affecteduser'] . '/files');
         $exist = $this->view->file_exists($activity['file']);
         $is_dir = $this->view->is_dir($activity['file']);
         $tmpl->assign('previewLink', $this->getPreviewLink($activity['file'], $is_dir));
         // show a preview image if the file still exists
         $mimeType = Files::getMimeType($activity['file']);
         if ($mimeType && !$is_dir && $this->preview->isMimeSupported($mimeType) && $exist) {
             $tmpl->assign('previewImageLink', $this->urlGenerator->linkToRoute('core_ajax_preview', array('file' => $activity['file'], 'x' => 150, 'y' => 150)));
         } else {
             $mimeTypeIcon = Template::mimetype_icon($is_dir ? 'dir' : $mimeType);
             $mimeTypeIcon = substr($mimeTypeIcon, -4) === '.png' ? substr($mimeTypeIcon, 0, -4) . '.svg' : $mimeTypeIcon;
             $tmpl->assign('previewImageLink', $mimeTypeIcon);
             $tmpl->assign('previewLinkIsDir', true);
         }
     }
     return $tmpl->fetchPage();
 }
開發者ID:AARNet,項目名稱:activity,代碼行數:34,代碼來源:display.php

示例2: download

 public function download($filename)
 {
     $file = basename($filename);
     $filename = $this->config->getBackupBase() . $file;
     // Prevent directory traversal
     if (strlen($file) < 3 || !@file_exists($filename)) {
         exit;
     }
     $mime = \OCP\Files::getMimeType($filename);
     return new DataDownloadResponse(file_get_contents($filename), $file, $mime);
 }
開發者ID:FelixHsieh,項目名稱:updater,代碼行數:11,代碼來源:backupcontroller.php

示例3: basename

 * ownCloud - Updater plugin
 *
 * @author Victor Dubiniuk
 * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\Updater;

\OCP\JSON::checkAdminUser();
\OCP\JSON::callCheck();
$file = basename(@$_GET["filename"]);
// Prevent directory traversal
if (strlen($file) < 3) {
    exit;
}
$filename = App::getBackupBase() . $file;
if (!@file_exists($filename)) {
    exit;
}
header('Content-Type:' . \OCP\Files::getMimeType($filename));
if (preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) {
    header('Content-Disposition: attachment; filename="' . rawurlencode(basename($filename)) . '"');
} else {
    header('Content-Disposition: attachment; filename*=UTF-8\'\'' . rawurlencode(basename($filename)) . '; filename="' . rawurlencode(basename($filename)) . '"');
}
\OCP\Response::disableCaching();
header('Content-Length: ' . filesize($filename));
\OC_Util::obEnd();
readfile($filename);
開發者ID:samj1912,項目名稱:repo,代碼行數:31,代碼來源:download.php


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