Laravel s3 Storage 怎么生成一个指定域名的下载连接?

$url = Storage::disk('s3')->getTemporaryUrl('a.txt','+1 hours')使用的是内网endpoint(https://s3-internal.amazonaws.com)生成的是配置中的endpoint的url如https://s3-internal.amazonaws.com/a.txt?query.

有没有什么方法可以生成指定域名的url(如自有cdnhttps://file-cdn.domain.com)

// function temporaryUrl
    public function temporaryUrl($path, $expiration, array $options = [])
    {
        $adapter = $this->driver->getAdapter();

        if ($adapter instanceof CachedAdapter) {
            $adapter = $adapter->getAdapter();
        }

        if (method_exists($adapter, 'getTemporaryUrl')) {
            return $adapter->getTemporaryUrl($path, $expiration, $options);
        } elseif ($adapter instanceof AwsS3Adapter) {
            return $this->getAwsTemporaryUrl($adapter, $path, $expiration, $options);
        } else {
            throw new RuntimeException('This driver does not support creating temporary URLs.');
        }
    }

// function getAwsTemporaryUrl
public function getAwsTemporaryUrl($adapter, $path, $expiration, $options)\
{
  $client = $adapter->getClient();

  $command = $client->getCommand('GetObject', array_merge([
  'Bucket' => $adapter->getBucket(),
  'Key' => $adapter->getPathPrefix().$path,
  ], $options));

 return (string) $client->createPresignedRequest(
  $command, $expiration
  )->getUri();
}
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 2

s3 配置域名解析

4年前 评论
cevin (楼主) 4年前

字符串替换??

4年前 评论
cevin (楼主) 4年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!