本文整理汇总了PHP中OC_Helper::getSecureMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Helper::getSecureMimeType方法的具体用法?PHP OC_Helper::getSecureMimeType怎么用?PHP OC_Helper::getSecureMimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Helper
的用法示例。
在下文中一共展示了OC_Helper::getSecureMimeType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetSecureMimeType
function testGetSecureMimeType()
{
$dir = OC::$SERVERROOT . '/tests/data';
$result = OC_Helper::getSecureMimeType('image/svg+xml');
$expected = 'text/plain';
$this->assertEquals($result, $expected);
$result = OC_Helper::getSecureMimeType('image/png');
$expected = 'image/png';
$this->assertEquals($result, $expected);
}
示例2: sendHeaders
/**
* @param string $filename
* @param string $name
*/
private static function sendHeaders($filename, $name)
{
OC_Response::setContentDispositionHeader($name, 'attachment');
header('Content-Transfer-Encoding: binary');
OC_Response::disableCaching();
$filesize = \OC\Files\Filesystem::filesize($filename);
header('Content-Type: ' . \OC_Helper::getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename)));
if ($filesize > -1) {
OC_Response::setContentLengthHeader($filesize);
}
}
示例3: getContentType
/**
* Returns the mime-type for a file
*
* If null is returned, we'll assume application/octet-stream
*
* @return mixed
*/
public function getContentType() {
$mimeType = $this->info->getMimetype();
// PROPFIND needs to return the correct mime type, for consistency with the web UI
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PROPFIND') {
return $mimeType;
}
return \OC_Helper::getSecureMimeType($mimeType);
}
示例4: getContentType
/**
* Returns the mime-type for a file
*
* If null is returned, we'll assume application/octet-stream
*
* @return mixed
*/
public function getContentType()
{
$mimeType = $this->info->getMimetype();
return \OC_Helper::getSecureMimeType($mimeType);
}
示例5: getContentType
/**
* Returns the mime-type for a file
*
* If null is returned, we'll assume application/octet-stream
*
* @return mixed
*/
public function getContentType()
{
if (isset($this->fileinfo_cache['mimetype'])) {
$mimeType = $this->fileinfo_cache['mimetype'];
} else {
$mimeType = \OC\Files\Filesystem::getMimeType($this->path);
}
return \OC_Helper::getSecureMimeType($mimeType);
}
示例6: list
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
OCP\JSON::checkAppEnabled('files_versions');
OCP\JSON::checkLoggedIn();
$file = $_GET['file'];
$revision = (int) $_GET['revision'];
list($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($file);
$versionName = '/' . $uid . '/files_versions/' . $filename . '.v' . $revision;
$view = new OC\Files\View('/');
$ftype = \OC_Helper::getSecureMimeType($view->getMimeType('/' . $uid . '/files/' . $filename));
header('Content-Type:' . $ftype);
OCP\Response::setContentDispositionHeader(basename($filename), 'attachment');
OCP\Response::disableCaching();
OCP\Response::setContentLengthHeader($view->filesize($versionName));
OC_Util::obEnd();
$view->readfile($versionName);
示例7: header
<?php
// Check if we are a user
OCP\User::checkLoggedIn();
$filename = $_GET["file"];
if (!\OC\Files\Filesystem::file_exists($filename)) {
header("HTTP/1.0 404 Not Found");
$tmpl = new OCP\Template('', '404', 'guest');
$tmpl->assign('file', $filename);
$tmpl->printPage();
exit;
}
$ftype = \OC_Helper::getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
header('Content-Type:' . $ftype);
OCP\Response::setContentDispositionHeader(basename($filename), 'attachment');
OCP\Response::disableCaching();
OCP\Response::setContentLengthHeader(\OC\Files\Filesystem::filesize($filename));
OC_Util::obEnd();
\OC\Files\Filesystem::readfile($filename);