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


PHP FilesystemInterface::getMetadata方法代码示例

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


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

示例1: load

 public function load($spiBinaryFileId)
 {
     try {
         $info = $this->filesystem->getMetadata($spiBinaryFileId);
     } catch (FileNotFoundException $e) {
         throw new BinaryFileNotFoundException($spiBinaryFileId);
     }
     $spiBinaryFile = new SPIBinaryFile();
     $spiBinaryFile->id = $spiBinaryFileId;
     $spiBinaryFile->mtime = new DateTime('@' . $info['timestamp']);
     $spiBinaryFile->size = $info['size'];
     return $spiBinaryFile;
 }
开发者ID:blankse,项目名称:ezpublish-kernel-1,代码行数:13,代码来源:Flysystem.php

示例2: uploadContents

 /**
  * Uploads raw contents to the service.
  *
  * @param string $contents
  * @return array    The meta of the file.
  */
 public function uploadContents($name, $contents)
 {
     $this->filesystem->write($name, $contents);
     $meta = $this->filesystem->getMetadata($name);
     $urlGenerator = app('Flarum\\Forum\\UrlGenerator');
     if (empty($this->settings->get('flagrow.image-upload.cdnUrl'))) {
         // if there is no cdnUrl
         $meta['url'] = $urlGenerator->toPath('assets/images/' . $name);
     } else {
         // if there is
         $meta['url'] = $this->settings->get('flagrow.image-upload.cdnUrl') . 'assets/images/' . $name;
     }
     return $meta;
 }
开发者ID:flagrow,项目名称:flarum-ext-image-upload,代码行数:20,代码来源:LocalAdapter.php

示例3: _stat

 /**
  * Return stat for given path.
  * Stat contains following fields:
  * - (int)    size    file size in b. required
  * - (int)    ts      file modification time in unix time. required
  * - (string) mime    mimetype. required for folders, others - optionally
  * - (bool)   read    read permissions. required
  * - (bool)   write   write permissions. required
  * - (bool)   locked  is object locked. optionally
  * - (bool)   hidden  is object hidden. optionally
  * - (string) alias   for symlinks - link target path relative to root path. optionally
  * - (string) target  for symlinks - link target path. optionally
  *
  * If file does not exists - returns empty array or false.
  *
  * @param  string  $path    file path
  * @return array|false
  **/
 protected function _stat($path)
 {
     $stat = array('mime' => 'directory', 'ts' => time(), 'read' => true, 'write' => true, 'locked' => false, 'hidden' => false, 'size' => 0);
     // 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);
     // 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:quepasso,项目名称:dashboard,代码行数:48,代码来源:ElFinderVolumeFlysystem.php

示例4: _stat

 /**
  * Return stat for given path.
  * Stat contains following fields:
  * - (int)    size    file size in b. required
  * - (int)    ts      file modification time in unix time. required
  * - (string) mime    mimetype. required for folders, others - optionally
  * - (bool)   read    read permissions. required
  * - (bool)   write   write permissions. required
  * - (bool)   locked  is object locked. optionally
  * - (bool)   hidden  is object hidden. optionally
  * - (string) alias   for symlinks - link target path relative to root path. optionally
  * - (string) target  for symlinks - link target path. optionally
  *
  * If file does not exists - returns empty array or false.
  *
  * @param  string $path file path
  * @return array|false
  **/
 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)) {
         // Check if the parent doesn't have this path
         if ($this->_dirExists($path)) {
             return $stat;
         }
         // Neither a file or directory exist, return empty
         return array();
     }
     try {
         $meta = $this->fs->getMetadata($path);
     } catch (\Exception $e) {
         return array();
     }
     if (false === $meta) {
         return $stat;
     }
     // Set item filename.extension to `name` if exists
     if (isset($meta['filename']) && isset($meta['extension'])) {
         $stat['name'] = $meta['filename'];
         if ($meta['extension'] !== '') {
             $stat['name'] .= '.' . $meta['extension'];
         }
     }
     // Get timestamp/size if available
     if (isset($meta['timestamp'])) {
         $stat['ts'] = $meta['timestamp'];
     }
     if (isset($meta['size'])) {
         $stat['size'] = $meta['size'];
     }
     // Check if file, if so, check mimetype when available
     if ($meta['type'] == 'file') {
         if (isset($meta['mimetype'])) {
             $stat['mime'] = $meta['mimetype'];
         } else {
             $stat['mime'] = $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:barryvdh,项目名称:elfinder-flysystem-driver,代码行数:75,代码来源:Driver.php

示例5: getType

 /**
  * @override
  * @inheritDoc
  */
 public function getType($path)
 {
     try {
         return $this->fs->getMetadata($path)['type'];
     } catch (Error $ex) {
     } catch (Exception $ex) {
     }
     throw new ReadException("File {$path} type could not be determined.", $ex);
 }
开发者ID:kraken-php,项目名称:framework,代码行数:13,代码来源:Filesystem.php

示例6: getSpecificFileInformation

 /**
  * Extracts a specific FileInformation from the FileSystems.
  *
  * @param string $fileIdentifier
  * @param string $containerPath
  * @param string $property
  *
  * @return bool|int|string
  * @throws \InvalidArgumentException
  */
 public function getSpecificFileInformation($fileIdentifier, $containerPath, $property)
 {
     $baseName = basename($fileIdentifier);
     $parts = explode('/', $fileIdentifier);
     $identifier = $this->canonicalizeAndCheckFileIdentifier($containerPath . PathUtility::basename($fileIdentifier));
     $file = $this->filesystem->getMetadata($fileIdentifier);
     switch ($property) {
         case 'size':
             return $file['size'];
         case 'atime':
             return $file['timestamp'];
         case 'mtime':
             return $file['timestamp'];
         case 'ctime':
             return $file['timestamp'];
         case 'name':
             return $baseName;
         case 'mimetype':
             return 'application/octet-stream';
         case 'identifier':
             return $identifier;
         case 'storage':
             return $this->storageUid;
         case 'identifier_hash':
             return $this->hashIdentifier($identifier);
         case 'folder_hash':
             if (1 < count($parts)) {
                 return $this->hashIdentifier($this->getParentFolderIdentifierOfIdentifier($identifier));
             } elseif (1 === count($parts)) {
                 return sha1('/');
             } else {
                 return '';
             }
         default:
             throw new \InvalidArgumentException(sprintf('The information "%s" is not available.', $property));
     }
 }
开发者ID:cedricziel,项目名称:fal-flysystem,代码行数:47,代码来源:FlysystemDriver.php

示例7: getType

 /**
  * Retrieve the entree type (file|dir).
  *
  * @return string file or dir
  */
 public function getType()
 {
     $metadata = $this->filesystem->getMetadata($this->path);
     return $metadata['type'];
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:10,代码来源:Handler.php

示例8: getMetadata

 /**
  * Get a file's metadata.
  *
  * @param string $path The path to the file.
  *
  * @throws FileNotFoundException
  *
  * @return array|false The file metadata or false on failure.
  */
 public function getMetadata($path)
 {
     return $this->fileSystem->getMetadata($path);
 }
开发者ID:graze,项目名称:data-file,代码行数:13,代码来源:FilesystemWrapper.php


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