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


PHP OC_Helper::getMimetypeDetector方法代码示例

本文整理汇总了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)));
开发者ID:samj1912,项目名称:repo,代码行数:31,代码来源:newfile.php

示例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;
     }
 }
开发者ID:perrich,项目名称:hubicWebApp,代码行数:20,代码来源:Hubic.php

示例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;
 }
开发者ID:droiter,项目名称:openwrt-on-android,代码行数:26,代码来源:amazons3.php

示例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;
 }
开发者ID:samj1912,项目名称:repo,代码行数:27,代码来源:amazons3.php

示例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");
开发者ID:mjensemble,项目名称:ownpad,代码行数:16,代码来源:app.php


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