當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。