本文整理汇总了PHP中OC_Helper::getMimetypeDetector方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Helper::getMimetypeDetector方法的具体用法?PHP OC_Helper::getMimetypeDetector怎么用?PHP OC_Helper::getMimetypeDetector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Helper
的用法示例。
在下文中一共展示了OC_Helper::getMimetypeDetector方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
return;
}
if (!\OC\Files\Filesystem::file_exists($dir . '/')) {
$result['data'] = array('message' => (string) $l10n->t('The target folder has been moved or deleted.'), 'code' => 'targetnotfound');
OCP\JSON::error($result);
exit;
}
$target = $dir . '/' . $fileName;
if (\OC\Files\Filesystem::file_exists($target)) {
$result['data'] = array('message' => (string) $l10n->t('The name %s is already used in the folder %s. Please choose a different name.', array($fileName, $dir)));
OCP\JSON::error($result);
exit;
}
$success = false;
$templateManager = OC_Helper::getFileTemplateManager();
$mimeType = OC_Helper::getMimetypeDetector()->detectPath($target);
$content = $templateManager->getTemplate($mimeType);
try {
if ($content) {
$success = \OC\Files\Filesystem::file_put_contents($target, $content);
} else {
$success = \OC\Files\Filesystem::touch($target);
}
} catch (\Exception $e) {
$result = ['success' => false, 'data' => ['message' => $e->getMessage()]];
OCP\JSON::error($result);
exit;
}
if ($success) {
$meta = \OC\Files\Filesystem::getFileInfo($target);
OCP\JSON::success(array('data' => \OCA\Files\Helper::formatFileInfo($meta)));
示例2: touch
public function touch($path, $mtime = null)
{
$path = $this->normalizePath($path);
if (is_null($mtime)) {
$mtime = time();
}
$metadata = array('timestamp' => $mtime);
if ($this->file_exists($path)) {
$object = $this->getContainer()->getPartialObject($path);
$object->saveMetadata($metadata);
return true;
} else {
$mimeType = \OC_Helper::getMimetypeDetector()->detectPath($path);
$customHeaders = array('content-type' => $mimeType);
$metadataHeaders = DataObject::stockHeaders($metadata);
$allHeaders = $customHeaders + $metadataHeaders;
$this->getContainer()->uploadObject($path, '', $allHeaders);
return true;
}
}
示例3: touch
public function touch($path, $mtime = null)
{
$path = $this->normalizePath($path);
$metadata = array();
if (!is_null($mtime)) {
$metadata = array('lastmodified' => $mtime);
}
$fileType = $this->filetype($path);
try {
if ($fileType !== false) {
if ($fileType === 'dir' && !$this->isRoot($path)) {
$path .= '/';
}
$this->getConnection()->copyObject(array('Bucket' => $this->bucket, 'Key' => $this->cleanKey($path), 'Metadata' => $metadata, 'CopySource' => $this->bucket . '/' . $path));
$this->testTimeout();
} else {
$mimeType = \OC_Helper::getMimetypeDetector()->detectPath($path);
$this->getConnection()->putObject(array('Bucket' => $this->bucket, 'Key' => $this->cleanKey($path), 'Metadata' => $metadata, 'ContentType' => $mimeType));
$this->testTimeout();
}
} catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e);
return false;
}
return true;
}
示例4: touch
public function touch($path, $mtime = null)
{
$path = $this->normalizePath($path);
$metadata = array();
if (is_null($mtime)) {
$mtime = time();
}
$metadata = ['lastmodified' => gmdate(\Aws\Common\Enum\DateFormat::RFC1123, $mtime)];
$fileType = $this->filetype($path);
try {
if ($fileType !== false) {
if ($fileType === 'dir' && !$this->isRoot($path)) {
$path .= '/';
}
$this->getConnection()->copyObject(['Bucket' => $this->bucket, 'Key' => $this->cleanKey($path), 'Metadata' => $metadata, 'CopySource' => $this->bucket . '/' . $path, 'MetadataDirective' => 'REPLACE']);
$this->testTimeout();
} else {
$mimeType = \OC_Helper::getMimetypeDetector()->detectPath($path);
$this->getConnection()->putObject(['Bucket' => $this->bucket, 'Key' => $this->cleanKey($path), 'Metadata' => $metadata, 'Body' => '', 'ContentType' => $mimeType, 'MetadataDirective' => 'REPLACE']);
$this->testTimeout();
}
} catch (S3Exception $e) {
\OCP\Util::logException('files_external', $e);
return false;
}
return true;
}
示例5:
<?php
/**
* ownCloud - OwnPad
*
* This file is licensed under the Affero General Public License
* version 3 or later. See the COPYING file.
*
* @author Olivier Tétard <olivier.tetard@miskin.fr>
* @copyright Olivier Tétard <olivier.tetard@miskin.fr>, 2015
*/
OCP\App::registerAdmin('ownpad', 'settings');
OCP\Util::addscript('ownpad', 'ownpad');
OCP\Util::addStyle('ownpad', 'ownpad');
\OC_Helper::getMimetypeDetector()->registerType("pad", "application/x-ownpad");
\OC_Helper::getMimetypeDetector()->registerType("calc", "application/x-ownpad");