vivlong/phalapi-xoss

PhalApi 2.x 扩展类库:支持Qiniu、Aliyun、QCloud、HuaweiCloud的OSS扩展。

dev-master 2023-12-08 11:41 UTC

This package is auto-updated.

Last update: 2024-04-08 12:17:55 UTC


README

PhalApi 2.x扩展类库,支持Qiniu、Aliyun的OSS扩展。

安装和配置

修改项目下的composer.json文件,并添加:

    "vivlong/phalapi-xoss":"dev-master"

然后执行composer update

安装成功后,添加以下配置到/path/to/phalapi/config/app.php文件:

    /**
     * XOSS相关配置
     */
    'Xoss' =>  array(
        'aliyun' => array(
            'accessKeyId'       => '<yourAccessKeyId>',
            'accessKeySecret'   => '<yourAccessKeySecret>',
            'bucket'            => '<yourBucketName>',
            'endpoint'          => 'https://your-endpoint',
            'isCName'           => false,
            'securityToken'     => null,
            'requestProxy'      => null,
        ),
        'qiniu' =>  array(
            'accessKey'   => '<yourAccessKey>',
            'secretKey'   => '<yourAccessSecretKey >',
        ),
        'qcloud' =>  array(
            'accessKey'   => '<yourAccessKey>',
            'secretKey'   => '<yourAccessSecretKey >',
            'region'      => 'ap-beijing',
            'schema'      => 'https',
        ),
        'huaweicloud' =>  array(
            'accessKeyId'       => '<yourAccessKeyId>',
            'accessKeySecret'   => '<yourSecretAccessKey>',
            'endpoint'          => 'https://your-endpoint',
        ),
    ),

并根据自己的情况修改填充。

注册

在/path/to/phalapi/config/di.php文件中,注册:

$di->xOss = function() {
        return new \PhalApi\Xoss\Lite();
};

使用

第一种使用方式:上传本地文件:

  \PhalApi\DI()->xOss->uploadFile($bucket, $object, $filePath);