leruge/filesystem

thinkphp 文件上传驱动

Maintainers

Package info

gitee.com/leruge/filesystem

pkg:composer/leruge/filesystem

Transparency log

Statistics

Installs: 8

Dependents: 0

Suggesters: 0

1.0.4 2026-08-01 02:28 UTC

This package is auto-updated.

Last update: 2026-08-01 02:48:21 UTC


README

目前仅支持华为OBS 支持压缩的图片格式 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff'

注意事项

  • 华为sdk使用的 `psr/http-message` 的版本是 `^1.0` ,现在大部分都是 `2.0` ,可以删除 `composer.lock` 文件,或者手动安装 `3.22.6` 版本以下的华为sdk
  • 如果安装 `3.22.6` 版本以上,在php8以上版本可能碰到报错,php8以上限制interface格式,所以需要修改一下,找到 `obs/esdk-obs-php/Obs/Internal/Common/CheckoutStream.php` 的35行和44行,改成如下,就是给 `getContents` 和 `read` 方法添加返回值
      public function getContents(): string {
          $contents = $this->stream->getContents();
          $length = strlen($contents);
          if ($this->expectedLength !== null && floatval($length) !== $this->expectedLength) {
              $this -> throwObsException($this->expectedLength, $length);
          }
          return $contents;
      }
    
      public function read(int $length): string {
          $string = $this->stream->read($length);
          if ($this->expectedLength !== null) {
              $this->readedCount += strlen($string);
              if ($this->stream->eof()) {
                  if (floatval($this->readedCount) !== $this->expectedLength) {
                      $this -> throwObsException($this->expectedLength, $this->readedCount);
                  }
              }
          }    
          return $string;
      }
    

安装

  • composer require leruge/filesystem

使用方式

  • 添加自定义磁盘即可
    'huawei' => [
      // 磁盘类型
      'type' => '\leruge\HuaWei',
      'ak' => '',
      'sk' => '',
      'endpoint' => '',
      'url' => '', // 自定义域名
      'bucket' => '', // 存储桶名称
      'compress_size' => 0, // 0是不压缩,单位是Kb,只有图片才压缩,并且开启 imagick 扩展
      'visibility' => 'public', // 可见性:public(公开)或 private(私有),默认 public
    ]