swoft-components / cloud-storage
cloud storage component for swoft, now support qiniu cloud storage
v3.0.0-beta
2025-06-21 11:16 UTC
Requires
- php: >=7.4
- ext-curl: *
- qiniu/php-sdk: ^7.14
- swoft-components/stdlib: ^1.0.0
- swoft/framework: ~2.0.0
Requires (Dev)
- ext-json: *
- phpunit/phpunit: ^7.5 || ^8.0
This package is auto-updated.
Last update: 2025-06-21 11:17:41 UTC
README
intro
This component is a cloud storage component for swoft. Current version 2.0.1, support qiniu cloud storage.
Install
- composer command
composer require swoft/cloud-storage
LICENSE
The Component is open-sourced software licensed under the Apache license.
Usage
// bean.php 中配置 bean 定义 // accessKey, secretKey 可以在 qiniu 个人中心获取, bucket 是七牛的空间名称 return [ ... 'qiniu' => [ 'bucket' => '配置七牛bucket名称' ], 'qiniuAuth' => [ 'accessKey' => '配置授权秘钥 key', 'secretKey' => '配置授权秘钥 secret', ], ... ];
// 上传文件到七牛云 use Swoft\CloudStorage\CloudStorage; use Swoft\CloudStorage\CloudStorageType; $cloudFileName = 'test.jpg'; $localFilePath = __DIR__. DIRECTORY_SEPARATOR. 'test.jpg'; // upload file to cloud qiniu $result = CloudStorage::upload($cloudFileName, $localFilePath, CloudStorageType::QINIU); var_dump($result);