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


PHP Filesystem::getSize方法代码示例

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


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

示例1: downloadAttachment

 /**
  * @param $filePath
  * @param $toBeDownloadedFileName
  *
  * @return int
  */
 public function downloadAttachment($filePath, $toBeDownloadedFileName = '')
 {
     if (!is_readable($this->currentPath . $filePath)) {
         $this->setError(self::ERROR_ATTACHMENT_FILE_DOES_NOT_EXIST);
     }
     if (empty($toBeDownloadedFileName)) {
         $toBeDownloadedFileName = basename($filePath);
         if (empty($toBeDownloadedFileName)) {
             $this->setError(self::ERROR_ATTACHMENT_DOES_NOT_EXIST);
         }
     }
     if ($this->hasError()) {
         return $this->errors;
     }
     $this->setHeadersForAttachmentDownload($toBeDownloadedFileName);
     if ($this->fileSystem->getSize($filePath) > DirectoryStructure::FS_DOWNLOAD_STREAM_AFTER_SIZE) {
         header('Content-Length: ' . $this->fileSystem->getSize($filePath));
         $stream = $this->fileSystem->readStream($filePath);
         while (!feof($stream)) {
             print fgets($stream, 1024);
             flush();
         }
         fclose($stream);
         exit;
     } else {
         ob_start();
         ob_start("ob_gzhandler");
         echo $this->fileSystem->get($filePath)->read();
         ob_end_flush();
         $gzippedContent = ob_get_contents();
         // store gzipped content to get size
         header('Content-Length: ' . strlen($gzippedContent));
         ob_end_flush();
         exit;
     }
 }
开发者ID:arbi,项目名称:MyCode,代码行数:42,代码来源:GenericDownloader.php

示例2: filesize

	/**
	 * {@inheritdoc}
	 */
	public function filesize($path) {
		if ($this->is_dir($path)) {
			return 0;
		} else {
			return $this->flysystem->getSize($this->buildPath($path));
		}
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:10,代码来源:flysystem.php

示例3: deployToRemote

 /**
  * Deploy files to the remote filesystem.
  *
  * @return void
  */
 public function deployToRemote()
 {
     $local_path = $this->relativeDumpPath();
     $files = $this->localAdapter->listContents($local_path);
     foreach ($files as $file) {
         $contents = $this->localAdapter->readStream($local_path . $file['basename']);
         $file_size = $this->localAdapter->getSize($local_path . $file['basename']);
         $this->out($this->parseString('Uploading %s (%s)', [$file['basename'], $this->formatBytes($file_size)], 'light_green'));
         $this->remoteAdapter->writeStream($local_path . $file['basename'], $contents);
     }
 }
开发者ID:JayBizzle,项目名称:mysqldumper,代码行数:16,代码来源:MySQLDumperCommand.php

示例4: _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

示例5: stream

 public function stream($video)
 {
     if (!Auth::user()->can('view-video')) {
         return view('errors.denied');
     }
     $filesystem = new Filesystem(new Adapter(base_path()));
     $location = '/files/video/' . $video;
     $stream = $filesystem->readStream($location);
     $headers = ["Content-Type" => $filesystem->getMimetype($location), "Content-Length" => $filesystem->getSize($location), "Content-disposition" => "attachment; filename=\"" . basename($location) . "\""];
     return Response::stream(function () use($stream) {
         fpassthru($stream);
     }, 200, $headers);
 }
开发者ID:nandeeshmp,项目名称:app,代码行数:13,代码来源:VideoController.php

示例6: size

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

示例7: getSize

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

示例8: processAssets

 /**
  * Render markup to load the CSS or JS assets.
  *
  * @param string[]          $attributes    Optional attributes, such as ['async']
  * @param string[]          $assets        The files to be processed
  * @param string            $extension     ".css" or ".js"
  * @param string            $source_dir    The folder containing the source assets
  * @param FilterInterface[] $filters       How to process these assets
  * @param string            $format_link   Template for an HTML link to the asset
  * @param string            $format_inline Template for an inline asset
  *
  * @return string
  */
 private function processAssets(array $attributes, array $assets, $extension, $source_dir, $filters, $format_link, $format_inline)
 {
     $hashes = [];
     $path = $this->getDestination();
     foreach ($assets as $asset) {
         if ($this->isAbsoluteUrl($asset)) {
             $hash = $this->hash($asset);
         } else {
             $hash = $this->hash($asset . $this->public->getTimestamp($source_dir . '/' . $asset));
         }
         if (!$this->public->has($path . '/' . $hash . $extension)) {
             if ($this->isAbsoluteUrl($asset)) {
                 $data = $this->getLoader()->loadUrl($asset);
             } else {
                 $data = $this->public->read($source_dir . '/' . $asset);
             }
             foreach ($filters as $filter) {
                 $data = $filter->filter($data, $asset, $this);
             }
             $this->public->write($path . '/' . $hash . $extension, $data);
             $this->public->write($path . '/' . $hash . '.min' . $extension, $data);
         }
         $hashes[] = $hash;
     }
     // The file name of our pipelined asset.
     $hash = $this->hash(implode('', $hashes));
     $asset_file = $path . '/' . $hash . '.min' . $extension;
     $this->concatenateFiles($path, $hashes, $hash, $extension);
     $this->concatenateFiles($path, $hashes, $hash, '.min' . $extension);
     $this->createGzip($asset_file);
     foreach ($this->notifiers as $notifier) {
         $notifier->created($asset_file);
     }
     if ($this->getDestinationUrl() === '') {
         $url = url($path);
     } else {
         $url = $this->getDestinationUrl();
     }
     if ($this->isEnabled()) {
         $inline_threshold = $this->getInlineThreshold();
         if ($inline_threshold > 0 && $this->public->getSize($asset_file) <= $inline_threshold) {
             return sprintf($format_inline, $this->public->read($asset_file));
         } else {
             return $this->htmlLinks($url, [$hash], '.min' . $extension, $format_link, $attributes);
         }
     } else {
         return $this->htmlLinks($url, $hashes, $extension, $format_link, $attributes);
     }
 }
开发者ID:fisharebest,项目名称:laravel-assets,代码行数:62,代码来源:Assets.php

示例9: testGetSize

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

示例10: getSize

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


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