alphasnow / aliyun-oss-laravel

Alibaba Cloud Object Storage Service For Laravel. 阿里云对象存储服务扩展包, 支持最新版的Laravel.
https://alphasnow.github.io/aliyun-oss-laravel/
MIT License
153 stars 16 forks source link

CDN 在哪里配置 #27

Closed wpjscc closed 1 year ago

wpjscc commented 1 year ago

运行环境 / Runtime environment

这些参数哪一个是cdn的域名配置

期望配置cdn后,签名的url返回的是cdn的域名

return [
    "driver" => "oss",
    "access_key_id" => env("OSS_ACCESS_KEY_ID"), // Required, YourAccessKeyId
    "access_key_secret" => env("OSS_ACCESS_KEY_SECRET"), // Required, YourAccessKeySecret
    "endpoint" => env("OSS_ENDPOINT"), // Required, Endpoint
    "bucket" => env("OSS_BUCKET"), // Required, Bucket
    "prefix" => env("OSS_PREFIX", ""), // For example: user/uploads
    "request_proxy" => env("OSS_PROXY", null), // Used by \OSS\OssClient
    "security_token" => env("OSS_TOKEN", null), // Used by \OSS\OssClient
    "is_cname" => env("OSS_CNAME", false), // If this is the CName and binded in the bucket.
    "use_ssl" => env("OSS_SSL", null), // Whether to use HTTPS
    "max_retries" => env("OSS_MAX_TRIES", null), // Sets the max retry count
    "timeout" => env("OSS_TIMEOUT", null), // The request timeout time
    "connect_timeout" => env("OSS_CONNECT_TIMEOUT", null), // The connection timeout time
    "enable_sts_in_url" => env("OSS_STS_URL", null), // Enable/disable STS in the URL
    "internal" => env("OSS_INTERNAL", null), // For example: oss-cn-shanghai-internal.aliyuncs.com
    "domain" => env("OSS_DOMAIN", null), // For example: oss.my-domain.com
    "reverse_proxy" => env("OSS_REVERSE_PROXY", false), // Whether to use the Reverse proxy, such as nginx
    "options" => [], // For example: [\OSS\OssClient::OSS_CHECK_MD5 => false]
    "macros" => [] // For example: [\App\Macros\ListBuckets::class,\App\Macros\CreateBucket::class]
];
alphasnow commented 1 year ago

@wpjscc 使用配置项 domain

wpjscc commented 1 year ago

@wpjscc 使用配置项 domain

domain 配置后貌似有问题,比如使用阿里云的cdn加速服务。

配置domain 后

"Unable to check existence for: storage/app/uploads/protected/647/c01/376/xxxxx.png" on line 19 of /xxxx/vendor/league/flysystem/src/UnableToCheckExistence.php

https://github.com/alphasnow/aliyun-oss-flysystem/blob/343c2fa98fc2af74abccdc81d01732f26b58acec/src/AliyunAdapter.php#L83

这个方法报错

    /**
     * {@inheritdoc}
     */
    public function fileExists(string $path): bool
    {
        try {
            return $this->client->doesObjectExist($this->bucket, $this->prefixer->prefixPath($path), $this->options->getOptions());
        } catch (OssException $exception) {
            throw UnableToCheckExistence::forLocation($path, $exception);
        }
    }
alphasnow commented 1 year ago

捕捉抛出异常的上一个异常查看详细信息 尝试修改"is_cname"=>true