# filesystem
**Repository Path**: leruge/filesystem
## Basic Information
- **Project Name**: filesystem
- **Description**: thinkphp的文件上传驱动
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-07-31
- **Last Updated**: 2026-08-01
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# thinkphp文件驱动
> 目前仅支持华为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` 方法添加返回值
```php
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`
## 使用方式
- 添加自定义磁盘即可
```php
'huawei' => [
// 磁盘类型
'type' => '\leruge\HuaWei',
'ak' => '',
'sk' => '',
'endpoint' => '',
'url' => '', // 自定义域名
'bucket' => '', // 存储桶名称
'compress_size' => 0, // 0是不压缩,单位是Kb,只有图片才压缩,并且开启 imagick 扩展
'visibility' => 'public', // 可见性:public(公开)或 private(私有),默认 public
]
```