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


PHP View::getMimeType方法代码示例

本文整理汇总了PHP中OC\Files\View::getMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP View::getMimeType方法的具体用法?PHP View::getMimeType怎么用?PHP View::getMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC\Files\View的用法示例。


在下文中一共展示了View::getMimeType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load

 /**
  * load text file
  *
  * @NoAdminRequired
  *
  * @param string $dir
  * @param string $filename
  * @return DataResponse
  */
 public function load($dir, $filename)
 {
     try {
         if (!empty($filename)) {
             $path = $dir . '/' . $filename;
             $filecontents = $this->view->file_get_contents($path);
             if ($filecontents !== false) {
                 $writable = $this->view->isUpdatable($path);
                 $mime = $this->view->getMimeType($path);
                 $mtime = $this->view->filemtime($path);
                 $encoding = mb_detect_encoding($filecontents . "a", "UTF-8, WINDOWS-1252, ISO-8859-15, ISO-8859-1, ASCII", true);
                 if ($encoding == "") {
                     // set default encoding if it couldn't be detected
                     $encoding = 'ISO-8859-15';
                 }
                 $filecontents = iconv($encoding, "UTF-8", $filecontents);
                 return new DataResponse(['filecontents' => $filecontents, 'writeable' => $writable, 'mime' => $mime, 'mtime' => $mtime], Http::STATUS_OK);
             } else {
                 return new DataResponse(['message' => (string) $this->l->t('Can not read the file.')], Http::STATUS_BAD_REQUEST);
             }
         } else {
             return new DataResponse(['message' => (string) $this->l->t('Invalid file path supplied.')], Http::STATUS_BAD_REQUEST);
         }
     } catch (\Exception $e) {
         $hint = method_exists($e, 'getHint') ? $e->getHint() : $e->getMessage();
         return new DataResponse(['message' => (string) $hint], Http::STATUS_BAD_REQUEST);
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:37,代码来源:filehandlingcontroller.php

示例2: load

 /**
  * load text file
  *
  * @NoAdminRequired
  *
  * @param string $dir
  * @param string $filename
  * @return DataResponse
  */
 public function load($dir, $filename)
 {
     try {
         if (!empty($filename)) {
             $path = $dir . '/' . $filename;
             // default of 4MB
             $maxSize = 4194304;
             if ($this->view->filesize($path) > $maxSize) {
                 return new DataResponse(['message' => (string) $this->l->t('This file is too big to be opened. Please download the file instead.')], Http::STATUS_BAD_REQUEST);
             }
             $fileContents = $this->view->file_get_contents($path);
             if ($fileContents !== false) {
                 $writable = $this->view->isUpdatable($path);
                 $mime = $this->view->getMimeType($path);
                 $mTime = $this->view->filemtime($path);
                 $encoding = mb_detect_encoding($fileContents . "a", "UTF-8, WINDOWS-1252, ISO-8859-15, ISO-8859-1, ASCII", true);
                 if ($encoding == "") {
                     // set default encoding if it couldn't be detected
                     $encoding = 'ISO-8859-15';
                 }
                 $fileContents = iconv($encoding, "UTF-8", $fileContents);
                 return new DataResponse(['filecontents' => $fileContents, 'writeable' => $writable, 'mime' => $mime, 'mtime' => $mTime], Http::STATUS_OK);
             } else {
                 return new DataResponse(['message' => (string) $this->l->t('Cannot read the file.')], Http::STATUS_BAD_REQUEST);
             }
         } else {
             return new DataResponse(['message' => (string) $this->l->t('Invalid file path supplied.')], Http::STATUS_BAD_REQUEST);
         }
     } catch (LockedException $e) {
         $message = (string) $this->l->t('The file is locked.');
         return new DataResponse(['message' => $message], Http::STATUS_BAD_REQUEST);
     } catch (ForbiddenException $e) {
         return new DataResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST);
     } catch (HintException $e) {
         $message = (string) $e->getHint();
         return new DataResponse(['message' => $message], Http::STATUS_BAD_REQUEST);
     } catch (\Exception $e) {
         $message = (string) $this->l->t('An internal server error occurred.');
         return new DataResponse(['message' => $message], Http::STATUS_BAD_REQUEST);
     }
 }
开发者ID:HomeThings,项目名称:files_texteditor,代码行数:50,代码来源:filehandlingcontroller.php

示例3: getMimeType

 public static function getMimeType($path)
 {
     return self::$defaultInstance->getMimeType($path);
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:4,代码来源:Filesystem.php

示例4: stream_close

 /**
  * @return bool
  */
 public function stream_close()
 {
     $this->flush();
     // if there is no valid private key return false
     if ($this->privateKey === false) {
         // cleanup
         if ($this->meta['mode'] !== 'r' && $this->meta['mode'] !== 'rb' && !$this->isLocalTmpFile) {
             // Disable encryption proxy to prevent recursive calls
             $proxyStatus = \OC_FileProxy::$enabled;
             \OC_FileProxy::$enabled = false;
             if ($this->rootView->file_exists($this->rawPath) && $this->size === 0) {
                 fclose($this->handle);
                 $this->rootView->unlink($this->rawPath);
             }
             // Re-enable proxy - our work is done
             \OC_FileProxy::$enabled = $proxyStatus;
         }
         // if private key is not valid redirect user to a error page
         Helper::redirectToErrorPage($this->session);
     }
     if ($this->meta['mode'] !== 'r' && $this->meta['mode'] !== 'rb' && $this->isLocalTmpFile === false && $this->size > 0 && $this->unencryptedSize > 0) {
         // only write keyfiles if it was a new file
         if ($this->newFile === true) {
             // Disable encryption proxy to prevent recursive calls
             $proxyStatus = \OC_FileProxy::$enabled;
             \OC_FileProxy::$enabled = false;
             // Fetch user's public key
             $this->publicKey = Keymanager::getPublicKey($this->rootView, $this->keyId);
             // Check if OC sharing api is enabled
             $sharingEnabled = \OCP\Share::isEnabled();
             // Get all users sharing the file includes current user
             $uniqueUserIds = $this->util->getSharingUsersArray($sharingEnabled, $this->relPath);
             $checkedUserIds = $this->util->filterShareReadyUsers($uniqueUserIds);
             // Fetch public keys for all sharing users
             $publicKeys = Keymanager::getPublicKeys($this->rootView, $checkedUserIds['ready']);
             // Encrypt enc key for all sharing users
             $this->encKeyfiles = Crypt::multiKeyEncrypt($this->plainKey, $publicKeys);
             // Save the new encrypted file key
             Keymanager::setFileKey($this->rootView, $this->util, $this->relPath, $this->encKeyfiles['data']);
             // Save the sharekeys
             Keymanager::setShareKeys($this->rootView, $this->util, $this->relPath, $this->encKeyfiles['keys']);
             // Re-enable proxy - our work is done
             \OC_FileProxy::$enabled = $proxyStatus;
         }
         // we need to update the file info for the real file, not for the
         // part file.
         $path = Helper::stripPartialFileExtension($this->rawPath);
         $fileInfo = array('mimetype' => $this->rootView->getMimeType($this->rawPath), 'encrypted' => true, 'unencrypted_size' => $this->unencryptedSize);
         // if we write a part file we also store the unencrypted size for
         // the part file so that it can be re-used later
         $this->rootView->putFileInfo($this->rawPath, $fileInfo);
         if ($path !== $this->rawPath) {
             $this->rootView->putFileInfo($path, $fileInfo);
         }
     }
     $result = fclose($this->handle);
     if ($result === false) {
         \OCP\Util::writeLog('Encryption library', 'Could not close stream, file could be corrupted', \OCP\Util::FATAL);
     }
     return $result;
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:64,代码来源:stream.php

示例5: getMimeType

 /**
  * Get the mimetype of the requested file 
  * @return string
  */
 protected function getMimeType()
 {
     return $this->view->getMimeType($this->filepath);
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:8,代码来源:download.php


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