本文整理汇总了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);