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


PHP Filesystem::getMimetype方法代码示例

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


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

示例1: execute

 /**
  * @return bool
  */
 public function execute()
 {
     if ($this->filesystem->getMimetype($this->filePath) == 'application/x-gzip') {
         if ($this->filesystem->getMimetype(str_replace('.tar.gz', '', $this->filePath)) == 'directory') {
             $this->filesystem->deleteDir(str_replace('.tar.gz', '', $this->filePath));
         }
     }
     if ($this->filesystem->getMimetype($this->filePath) == 'directory') {
         return $this->filesystem->deleteDir($this->filePath);
     } else {
         return $this->filesystem->delete($this->filePath);
     }
 }
开发者ID:sakalauskas,项目名称:backup-manager,代码行数:16,代码来源:DeleteFile.php

示例2: assets

 /**
  * Return admin assets
  * @param Response $response
  * @param $asset
  * @return Response|static
  * @throws FileNotFoundException
  */
 public function assets(Response $response, $asset)
 {
     $filesystem = new Filesystem(new Adapter(FS2ADMIN));
     $expires = 8640000;
     try {
         // generate cache data
         $timestamp_string = gmdate('D, d M Y H:i:s ', $filesystem->getTimestamp($asset)) . 'GMT';
         $etag = md5($filesystem->read($asset));
         $mime_type = $filesystem->getMimetype($asset);
         if (0 !== strpos($mime_type, 'image')) {
             $mime_type = 'text/css';
         }
         $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false;
         $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] : false;
         if (($if_none_match && $if_none_match == "\"{$etag}\"" || !$if_none_match) && ($if_modified_since && $if_modified_since == $timestamp_string)) {
             return $response->withStatus('304');
         } else {
             $response = $response->withHeader('Last-Modified', $timestamp_string)->withHeader('ETag', "\"{$etag}\"");
         }
         // send out content type, expire time and the file
         $response->getBody()->write($filesystem->read($asset));
         return $response->withHeader('Expires', gmdate('D, d M Y H:i:s ', time() + $expires) . 'GMT')->withHeader('Content-Type', $mime_type)->withHeader('Pragma', 'cache')->withHeader('Cache-Control', 'cache');
     } catch (FileNotFoundException $e) {
         throw $e;
     }
 }
开发者ID:frogsystem,项目名称:legacy-bridge,代码行数:33,代码来源:AdminController.php

示例3: getMimetype

 /**
  * @inheritdoc
  */
 public function getMimetype($path)
 {
     try {
         return $this->fileSystem->getMimetype($this->getInnerPath($path));
     } catch (FileNotFoundException $e) {
         throw $this->exceptionWrapper($e, $path);
     }
 }
开发者ID:petrknap,项目名称:php-filestorage,代码行数:11,代码来源:FileSystem.php

示例4: checkFileType

 /**
  * checkFileType
  * @param array                        $file
  * @param \League\Flysystem\Filesystem $fileReader
  * @param                              $type
  * @return bool
  * @throws \eig\Configurator\Exceptions\ConfiguratorException
  */
 protected function checkFileType(array $file, Filesystem $fileReader, $type)
 {
     $options = new Options();
     if ($fileReader->getMimetype($file['source']) == $options->configurationFileTypes[$type]) {
         return true;
     } else {
         throw new ConfiguratorException("Error {$file['source']} is not a PHP file", $code = 1);
     }
 }
开发者ID:excellentingenuity,项目名称:Configurator,代码行数:17,代码来源:FileTraits.php

示例5: getResources

function getResources($uploads_dir, $id, $maxWidth, $connection = 'default')
{
    $attachments = Attachment::on($connection)->where('id', $id)->get();
    if (count($attachments) == 1) {
        $attachment = $attachments[0];
        switch ($attachment->source) {
            case Source::EMAIL:
                $adapter = new Local($uploads_dir . '/email/');
                break;
            case Source::TWITTER:
                $adapter = new Local($uploads_dir . '/twitter/');
                break;
            case Source::TELEGRAM:
                $adapter = new Local($uploads_dir . '/telegram/');
                break;
            default:
                break;
        }
        $filesystem = new Filesystem($adapter);
        $filesystem->addPlugin(new ListWith());
        if ($filesystem->has($attachment->filePath)) {
            $data = $filesystem->read($attachment->filePath);
            $fp['data'] = $data;
            $fp['mime'] = $filesystem->getMimetype($attachment->filePath);
            if ($maxWidth > 0) {
                $imagine = new \Imagine\Gd\Imagine();
                $image = $imagine->load($data);
                $size = $image->getSize();
                if ($size->getWidth() > $maxWidth) {
                    // AWIDTH : AHEIGHT = NWIDTH : NHEIGHT
                    // HHEIGHT = AHEIGHT * NWIDTH / AWIDTH
                    $height = $size->getHeight() * $maxWidth / $size->getWidth();
                    $width = $maxWidth;
                    $fp['data'] = $image->resize(new Box($width, $height), ImageInterface::FILTER_UNDEFINED)->show('png');
                    //FILTER_QUADRATIC
                }
            }
            return $fp;
        }
    }
    return false;
}
开发者ID:BitPrepared,项目名称:OnlineOnsiteOngoing,代码行数:42,代码来源:functions.image.php

示例6: _stat

 /**
  * @inheritdoc
  */
 protected function _stat($path)
 {
     $stat = array('size' => 0, 'ts' => time(), 'read' => true, 'write' => true, 'locked' => false, 'hidden' => false, 'mime' => 'directory');
     // If root, just return from above
     if ($this->root == $path) {
         $stat['name'] = $this->root;
         return $stat;
     }
     // If not exists, return empty
     //        if ( !$this->fs->has($path)) {
     //            return array();
     //        }
     //
     //        $meta = $this->fs->getMetadata($path);
     try {
         $meta = $this->fs->getMetadata($path);
     } catch (FileNotFoundException $e) {
         $path = $path . '/';
         try {
             $meta = $this->fs->getMetadata($path);
         } catch (FileNotFoundException $e) {
             return array();
         }
     }
     // Get timestamp/size
     $stat['ts'] = isset($meta['timestamp']) ? $meta['timestamp'] : $this->fs->getTimestamp($path);
     $stat['size'] = isset($meta['size']) ? $meta['size'] : $this->fs->getSize($path);
     // Check if file, if so, check mimetype
     if ($meta['type'] == 'file') {
         $stat['mime'] = isset($meta['mimetype']) ? $meta['mimetype'] : $this->fs->getMimetype($path);
         $imgMimes = ['image/jpeg', 'image/png', 'image/gif'];
         if ($this->urlBuilder && in_array($stat['mime'], $imgMimes)) {
             $stat['url'] = $this->urlBuilder->getUrl($path, ['ts' => $stat['ts']]);
             $stat['tmb'] = $this->urlBuilder->getUrl($path, ['ts' => $stat['ts'], 'w' => $this->tmbSize, 'h' => $this->tmbSize, 'fit' => $this->options['tmbCrop'] ? 'crop' : 'contain']);
         }
     }
     //        if (!isset($stat['url']) && $this->fs->getUrl()) {
     //            $stat['url'] = 1;
     //        }
     return $stat;
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:44,代码来源:FlysystemDriver.php

示例7: image

 /**
  * Render image from filesystem
  * @param $image
  * @return mixed
  */
 public function image($image)
 {
     $filesystem = new Filesystem(new Adapter(base_path()));
     $location = '/files/video/' . $image;
     $mime_type = $filesystem->getMimetype($location);
     $file = $filesystem->read($location);
     return response($file, 200)->header('Content-Type', $mime_type);
 }
开发者ID:nandeeshmp,项目名称:app,代码行数:13,代码来源:VideoController.php

示例8: mimeType

 /**
  * Get the mime-type of a given file.
  *
  * @param  string  $path
  * @return string|false
  */
 public function mimeType($path)
 {
     return parent::getMimetype($path);
 }
开发者ID:weyii,项目名称:yii2-filesystem,代码行数:10,代码来源:Filesystem.php

示例9: mimetype

 /**
  * @return string
  */
 public function mimetype()
 {
     return $this->filesystem->getMimetype($this->path);
 }
开发者ID:lechimp-p,项目名称:flightcontrol,代码行数:7,代码来源:FSObject.php

示例10: testGetMimetype

 public function testGetMimetype()
 {
     $this->assertInternalType('string', $this->filesystem->getMimetype('2.txt'));
 }
开发者ID:apollopy,项目名称:flysystem-aliyun-oss,代码行数:4,代码来源:AliyunOssAdapterTest.php

示例11: getMimetype

 /**
  * Get a file's mimetype
  *
  * ```php
  * getMimetype('cache/file.tmp')
  * getMimetype('~/file.tmp$/')
  * ```
  *
  * @param  string $path path to file or regexp pattern
  * @return string|false file mimetype or FALSE when fails
  *                      to fetch mimetype from existing file
  */
 public function getMimetype($path)
 {
     if (StringHelper::isRegexp($path) && !($path = $this->searchByPattern($path))) {
         return false;
     }
     try {
         return parent::getMimetype($path);
     } catch (\Exception $e) {
         $this->errors[] = $e->getMessage();
     }
     return false;
 }
开发者ID:romeoz,项目名称:rock-file,代码行数:24,代码来源:FileManager.php


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