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


PHP Util::contentSize方法代码示例

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


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

示例1: getSize

 /**
  * @inheritdoc
  */
 public function getSize($path)
 {
     if (!($decrypted = $this->read($path))) {
         return false;
     }
     $size = Util::contentSize($decrypted['contents']);
     return compact('path', 'size');
 }
开发者ID:twistor,项目名称:flysystem-encrypt,代码行数:11,代码来源:EncryptAdapter.php

示例2: write

 /**
  * Write a file
  *
  * @param   string  $path
  * @param   string  $contents
  * @param   mixed   $config
  * @return  array   file metadata
  */
 public function write($path, $contents, $config = null)
 {
     $config = Util::ensureConfig($config);
     $options = $this->getOptions($path, array('Body' => $contents, 'ContentType' => Util::guessMimeType($path, $contents), 'ContentLength' => Util::contentSize($contents)), $config);
     $result = $this->client->putObject($options);
     if ($result === false) {
         return false;
     }
     return $this->normalizeObject($options);
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:18,代码来源:AwsS3.php

示例3: write

 /**
  * Write a file
  *
  * @param   string  $path
  * @param   string  $contents
  * @param   mixed   $config
  * @return  array   file metadata
  */
 public function write($path, $contents, $config = null)
 {
     $config = Util::ensureConfig($config);
     $options = $this->getOptions($path, array('Body' => $contents, 'ContentType' => Util::contentMimetype($contents), 'ContentLength' => Util::contentSize($contents)));
     if ($visibility = $config->get('visibility')) {
         $options['ACL'] = $visibility === AdapterInterface::VISIBILITY_PUBLIC ? 'public-read' : 'private';
     }
     $this->client->putObject($options);
     if ($visibility) {
         $options['visibility'] = $visibility;
     }
     return $this->normalizeObject($options);
 }
开发者ID:luoshulin,项目名称:falcon,代码行数:21,代码来源:AwsS3.php

示例4: upload

 /**
  * Upload an object.
  *
  * @param        $path
  * @param        $body
  * @param Config $config
  *
  * @return array
  */
 protected function upload($path, $body, Config $config)
 {
     $key = $this->applyPathPrefix($path);
     $options = $this->getOptionsFromConfig($config);
     $acl = isset($options['ACL']) ? $options['ACL'] : 'private';
     if (!isset($options['ContentType']) && is_string($body)) {
         $options['ContentType'] = Util::guessMimeType($path, $body);
     }
     if (!isset($options['ContentLength'])) {
         $options['ContentLength'] = is_string($body) ? Util::contentSize($body) : Util::getStreamSize($body);
     }
     $this->s3Client->upload($this->bucket, $key, $body, $acl, ['params' => $options]);
     return $this->normalizeResponse($options, $key);
 }
开发者ID:janhartigan,项目名称:flysystem-aws-s3-v3,代码行数:23,代码来源:AwsS3Adapter.php

示例5: write

 /**
  * {@inheritdoc}
  */
 public function write($path, $contents, Config $config)
 {
     $options = $this->getOptions($path, ['Body' => $contents, 'ContentType' => Util::guessMimeType($path, $contents), 'ContentLength' => Util::contentSize($contents)], $config);
     return $this->writeObject($options);
 }
开发者ID:SevenMonks,项目名称:100cities-dev,代码行数:8,代码来源:AwsS3Adapter.php

示例6: write

 /**
  * Write a new file.
  *
  * @param string $path
  * @param string $contents
  * @param Config $config Config object
  * @return array|false false on failure file meta data on success
  */
 public function write($path, $contents, Config $config)
 {
     $object = $this->applyPathPrefix($path);
     $options = $this->getOptionsFromConfig($config);
     if (!isset($options[OssClient::OSS_LENGTH])) {
         $options[OssClient::OSS_LENGTH] = Util::contentSize($contents);
     }
     if (!isset($options[OssClient::OSS_CONTENT_TYPE])) {
         $options[OssClient::OSS_CONTENT_TYPE] = Util::guessMimeType($path, $contents);
     }
     try {
         $this->client->putObject($this->bucket, $object, $contents, $options);
     } catch (OssException $e) {
         return false;
     }
     $type = 'file';
     $result = compact('type', 'path', 'contents');
     $result['mimetype'] = $options[OssClient::OSS_CONTENT_TYPE];
     $result['size'] = $options[OssClient::OSS_LENGTH];
     return $result;
 }
开发者ID:apollopy,项目名称:flysystem-aliyun-oss,代码行数:29,代码来源:AliyunOssAdapter.php

示例7: getMetadata

 /**
  * {@inheritdoc}
  */
 public function getMetadata($path)
 {
     $info = $this->getPathInfo($path);
     if (!$this->has($path)) {
         throw new \League\Flysystem\FileNotFoundException("File not found at path: {$info['path']}");
     }
     $metadata = json_decode($this->redis->hget($this->applyPathPrefix($info['dirname']), $info['basename']), TRUE);
     if ($metadata['type'] === 'file') {
         $metadata['contents'] = base64_decode($metadata['contents']);
         $metadata += ['size' => Util::contentSize($metadata['contents']), 'mimetype' => Util::guessMimeType($metadata['path'], $metadata['contents'])];
         unset($metadata['contents']);
     }
     return $metadata;
 }
开发者ID:danhunsaker,项目名称:flysystem-redis,代码行数:17,代码来源:RedisAdapter.php

示例8: write

 /**
  * {@inheritdoc}
  */
 public function write($path, $contents, Config $config)
 {
     $options = $this->getOptions($path, ['Content' => $contents, 'ContentType' => Util::guessMimeType($path, $contents), 'ContentLength' => Util::contentSize($contents)], $config);
     if ($this->client->putObject($options) === false) {
         var_dump(11);
         exit;
         return false;
     }
     return true;
 }
开发者ID:hellojujian,项目名称:aliyun-oss,代码行数:13,代码来源:AliyunOssAdapter.php

示例9: write

 /**
  * {@inheritdoc}
  */
 public function write($path, $contents, Config $config)
 {
     $options = $this->getOptions($path, ['Content' => $contents, 'ContentType' => Util::guessMimeType($path, $contents), 'ContentLength' => Util::contentSize($contents)], $config);
     try {
         if ($this->client->putObject($options) === false) {
             return false;
         }
         return true;
     } catch (OSSException $e) {
         return false;
     } catch (ClientException $e) {
         return false;
     }
 }
开发者ID:skyling,项目名称:aliyun-oss,代码行数:17,代码来源:AliyunOssAdapter.php

示例10: write

 /**
  * Write a file
  *
  * @param   string  $path
  * @param   string  $contents
  * @param   mixed   $config
  * @return  array   file metadata
  */
 public function write($path, $contents, $config = null)
 {
     $mimeType = Util::guessMimeType($path, $contents);
     if (isset($config)) {
         if (isset($config["mimeType"])) {
             $mimeType = $config["mimeType"];
         }
     }
     $config = Util::ensureConfig($config);
     $options = $this->getOptions($path, array('ContentType' => $mimeType, 'ContentLength' => Util::contentSize($contents)), $config);
     $dirname = dirname($path);
     $filename = basename($path);
     if ($this->has($path)) {
         $isUpdate = true;
         $file = $this->service->files->get($path);
     } else {
         $file = new Google_Service_Drive_DriveFile();
         $file->setTitle($filename);
         $file->setMimeType($mimeType);
         if ($dirname != ".") {
             $parent = new Google_Service_Drive_ParentReference();
             $parent->setId($dirname);
             $file->setParents(array($parent));
         }
     }
     if (isset($isUpdate)) {
         $result = $this->service->files->update($file['id'], $file, array('data' => $contents, 'mimeType' => $mimeType, 'uploadType' => "multipart"));
     } else {
         $result = $this->service->files->insert($file, array('data' => $contents, 'mimeType' => $mimeType, 'uploadType' => "multipart"));
     }
     if ($result === false) {
         return false;
     }
     $result['mimeType'] = $mimeType;
     $result['title'] = $filename;
     $result['id'] = $result->getId();
     return $this->normalizeObject($result);
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:46,代码来源:GoogleDrive.php

示例11: write

 /**
  * Write a file
  *
  * @param   string $path
  * @param   string $contents
  * @param   mixed  $config
  *
  * @return  array   file metadata
  */
 public function write($path, $contents, $config = null)
 {
     $options = $this->getOptions($path, array('Body' => $contents, 'ContentType' => Util::guessMimeType($path, $contents), 'ContentLength' => Util::contentSize($contents)), $config = Util::ensureConfig($config));
     return $this->writeObject($options);
 }
开发者ID:limweb,项目名称:webappservice,代码行数:14,代码来源:AwsS3.php

示例12: kvPut

 protected function kvPut($path, $contents, Config $config, $file = null)
 {
     $addOrSet = is_null($file) ? 'set' : 'add';
     $file['contents'] = $contents;
     $file['timestamp'] = time();
     $file['size'] = Util::contentSize($contents);
     if ($visibility = $config->get('visibility')) {
         $file['visibility'] = $visibility;
     }
     if ($this->client->{$addOrSet}($path, $file)) {
         return $file + compact('path');
     }
     return false;
 }
开发者ID:litp,项目名称:flysystem-sae,代码行数:14,代码来源:KvdbAdapter.php

示例13: update

 /**
  * {@inheritdoc}
  */
 public function update($path, $contents, Config $config)
 {
     if (!$this->hasFile($path)) {
         return false;
     }
     $this->storage[$path]['contents'] = $contents;
     $this->storage[$path]['timestamp'] = time();
     $this->storage[$path]['size'] = Util::contentSize($contents);
     $this->storage[$path]['mimetype'] = Util::guessMimeType($path, $contents);
     if ($visibility = $config->get('visibility')) {
         $this->setVisibility($path, $visibility);
     }
     return $this->getMetadata($path);
 }
开发者ID:twistor,项目名称:flysystem-memory-adapter,代码行数:17,代码来源:MemoryAdapter.php

示例14: write

 /**
  * Write a file
  *
  * @param   string $path
  * @param   string $contents
  * @param   mixed  $config
  *
  * @return  array   file metadata
  */
 public function write($path, $contents, $config = null)
 {
     $options = $this->getOptions($path, array('Body' => $contents, 'ContentType' => Util::guessMimeType($path, $contents), 'ContentLength' => Util::contentSize($contents)), Util::ensureConfig($config));
     $multipartLimit = $this->mbToBytes($options['Multipart']);
     if ($options['ContentLength'] > $multipartLimit) {
         $result = $this->putObjectMultipart($options);
     } else {
         $result = $this->client->putObject($options);
     }
     if ($result === false) {
         return false;
     }
     return $this->normalizeObject($options);
 }
开发者ID:simnom,项目名称:Europeana-Professional,代码行数:23,代码来源:AwsS3.php

示例15: update

 /**
  * {@inheritdoc}
  */
 public function update($path, $contents, Config $config)
 {
     if (!$this->hasFile($path)) {
         return false;
     }
     $this->storage[$path]['contents'] = $contents;
     $this->storage[$path]['timestamp'] = time();
     $this->storage[$path]['size'] = Util::contentSize($contents);
     if ($visibility = $config->get('visibility')) {
         $this->storage[$path]['visibility'] = $visibility;
     }
     return $this->storage[$path] + compact('path');
 }
开发者ID:BenjaminPaap,项目名称:flysystem-memory,代码行数:16,代码来源:MemoryAdapter.php


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