本文整理匯總了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();
}
示例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);
}
示例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);