shaozeming/aliyun-oss

继承阿里云Oss composer 包最新版本进行封装的composer package,整理配置便于管理

v1.0.0 2019-03-12 05:18 UTC

This package is auto-updated.

Last update: 2024-10-22 13:49:08 UTC


README

同胞兄弟

Installing

$ composer require shaozeming/aliyun-oss -v

configuration

拷贝项目下src/config.php到你项目中,进行配置其中oss。

配置示例代码:

return [

       /**
        * oss 配置
        */
       'oss' => [
           'AccessKeyID' => 'LT********cgJFsp',
           'AccessKeySecret' => 'fNcK*************d6Gn',
           'endpoint' => 'oss-cn-beijing.aliyuncs.com',
           'bucket' => 'miji***a365',  //
           'is_cname' => false,  // 是否使用自己绑定域名
           'is_ssl' => false,  // 是否使用https
           'timeout' => 3600,  // 授权访问默认时间
       ]
];

Example

use ShaoZeMing\AliOss\Services\OSSService;

 
    
           try {
                    $oss = new OSSService($config);
                    $result =  $oss->createBucket('shaozeming'); // 创建Bucket
                   
                   
                  //  $bucket= " <yourBucketName>";
                  //  $object = "<yourObjectName>";  
                  //  $content = "Hi, OSS.";
                  //  $result =  $oss->putObject($bucket,$object,$content); // 上传文件
                  //  .....
                    print_r($result);
                    return $result;
                } catch (OssException $e) {
                     $err = "Error : 错误:" . $e->getMessage();
                     echo $err . PHP_EOL;
                 } catch (\Exception $e) {
        //
                    $err = "Error : 错误:" . $e->getMessage();
                    echo $err . PHP_EOL;
        
                }
       

License

MIT