Skip to content

阿里雲实例 配置文件可以改会这样的配置吗,现在main 版本有的参数无法配置 #24

@ybbhui90

Description

@ybbhui90

`<?php
/**

  • @desc 阿里云OSS适配器
  • @author Tinywan(ShaoBo Wan)
  • @Date 2022/3/7 19:54
    */
    declare(strict_types=1);

namespace Tinywan\Storage\Adapter;

use OSS\Core\OssException;
use OSS\OssClient;
use Throwable;
use Tinywan\Storage\Exception\StorageException;
use OSS\Credentials\StaticCredentialsProvider;

class OssAdapter extends AdapterAbstract
{
protected $instance = null;

/**
 * @desc: 阿里雲实例
 *
 * @throws OssException
 */
public function getInstance(): ?OssClient
{
    if (is_null($this->instance)) {
        $provider = new StaticCredentialsProvider($this->config['accessKeyId'], $this->config['accessKeySecret'], null);
        $this->instance = new OssClient([
            'provider'  => $provider,
            'endpoint'=>$this->config['endpoint'],
            'cname' => $this->config['cname'],
            'signatureVersion' => $this->config['signatureVersion'],
            'region'    => $this->config['region'],
        ]);
        $this->instance->setUseSSL(true);
    }

    return $this->instance;
}

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions