当前位置: 首页>>代码示例>>PHP>>正文


PHP OC_Helper::getSecureMimeType方法代码示例

本文整理汇总了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);
 }
开发者ID:reverserob,项目名称:core,代码行数:10,代码来源:helper.php

示例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);
     }
 }
开发者ID:hyb148,项目名称:core,代码行数:15,代码来源:files.php

示例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);
	}
开发者ID:BacLuc,项目名称:newGryfiPage,代码行数:16,代码来源:file.php

示例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);
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:12,代码来源:file.php

示例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);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:16,代码来源:file.php

示例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);
开发者ID:alfrescoo,项目名称:core,代码行数:31,代码来源:download.php

示例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);
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:19,代码来源:download.php


注:本文中的OC_Helper::getSecureMimeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。