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


PHP Filesystem::getMetadata方法代码示例

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


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

示例1: remove

 /**
  * Remove file or a directory
  *
  * @param $path
  * @return void
  */
 public function remove($path)
 {
     if (!$this->filesystem->has($path)) {
         return;
     }
     $meta = $this->filesystem->getMetadata($path);
     if ($meta['type'] === 'file') {
         $this->filesystem->delete($path);
     } else {
         $this->filesystem->deleteDir($path);
     }
 }
开发者ID:karion,项目名称:mydrinks,代码行数:18,代码来源:FlySystemAdapter.php

示例2: testGetMetadata

 public function testGetMetadata()
 {
     $data = $this->filesystem->getMetadata('2.txt');
     $this->assertArrayHasKey('type', $data);
     $this->assertArrayHasKey('dirname', $data);
     $this->assertArrayHasKey('path', $data);
     $this->assertArrayHasKey('timestamp', $data);
     $this->assertArrayHasKey('mimetype', $data);
     $this->assertArrayHasKey('size', $data);
 }
开发者ID:apollopy,项目名称:flysystem-aliyun-oss,代码行数:10,代码来源:AliyunOssAdapterTest.php

示例3: filetype

	/**
	 * {@inheritdoc}
	 */
	public function filetype($path) {
		if ($path === '' or $path === '/' or $path === '.') {
			return 'dir';
		}
		try {
			$info = $this->flysystem->getMetadata($this->buildPath($path));
		} catch (FileNotFoundException $e) {
			return false;
		}
		return $info['type'];
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:14,代码来源:flysystem.php

示例4: getMetadata

 /**
  * @inheritdoc
  */
 public function getMetadata($path)
 {
     try {
         $return = $this->fileSystem->getMetadata($this->getInnerPath($path));
     } catch (FileNotFoundException $e) {
         throw $this->exceptionWrapper($e, $path);
     }
     if ($return !== false) {
         $return = array_merge($return, pathinfo($path), ["path" => $path]);
     }
     return $return;
 }
开发者ID:petrknap,项目名称:php-filestorage,代码行数:15,代码来源:FileSystem.php

示例5: get

 /**
  * Get an object from the filesystem based on its path.
  *
  * Dependening on the adapter in the underlying flysystem, this might treat
  * empty directories as if they would not exist (e.g. for ZipArchiveAdapter).
  *
  * @param   string  $path
  * @return  FSObject|null
  */
 public function get($path)
 {
     // TODO: This does not deal with ~ for home directory.
     assert(is_string($path));
     // For ZipArchiveAdapter this is required to get the directories correctly,
     // as Filesystem::get will raise.
     if ($this->filesystem->listContents($path)) {
         return new Directory($this, $path);
     }
     try {
         $info = $this->filesystem->getMetadata($path);
         if ($info) {
             if ($info["type"] == "file") {
                 return new File($this, $path);
             }
             return new Directory($this, $path);
         }
     } catch (\League\Flysystem\FileNotFoundException $e) {
         return null;
     }
     return null;
 }
开发者ID:lechimp-p,项目名称:flightcontrol,代码行数:31,代码来源:Flightcontrol.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: stat

 /**
  * @param Payload $payload
  * @param Messenger $messenger
  * @return PromiseInterface
  */
 public function stat(Payload $payload, Messenger $messenger)
 {
     $stat = $this->flysystem->getMetadata($payload['path']);
     return \React\Promise\resolve(['size' => $stat['size'], 'atime' => $stat['timestamp'], 'mtime' => $stat['timestamp'], 'ctime' => $stat['timestamp']]);
 }
开发者ID:WyriHaximus,项目名称:reactphp-filesystem-flysystem,代码行数:10,代码来源:Worker.php

示例8: getMetadata

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


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