gpt4 book ai didi

Laravel 的文件系统与 s3 使用错误的 url

转载 作者:行者123 更新时间:2023-12-02 10:45:35 25 4
gpt4 key购买 nike

我正在使用 Laravel 的文件系统在 s3 上存储项目,但我得到了错误的 URL。

Storage::disk('s3')->put('file.txt', 'Contents');

给我错误

CurlException in CurlMulti.php line 359:
[curl] 6: Could not resolve host: mybucket.s3.website-us-east-1.amazonaws.com [url] https://mybucket.s3.website-us-east-1.amazonaws.com/file.txt

此网址

mybucket.s3.website-us-east-1.amazonaws.com

应该是

mybucket.s3-website-us-east-1.amazonaws.com

config/filesystem.php

's3' => [
'driver' => 's3',
'key' => env('S3_KEY'),
'secret' => env('S3_SECRET'),
'region' => env('S3_REGION'),
'bucket' => env('S3_BUCKET'),
],

.env

S3_KEY=MYKEY
S3_SECRET=mySecr3tmySecr3tmySecr3tmySecr3t
S3_REGION=website-us-east-1
S3_BUCKET=mybucket

最佳答案

我最终找到了两个答案。

One solution是完全删除区域引用

's3' => [
'driver' => 's3',
'key' => env('S3_KEY'),
'secret' => env('S3_SECRET'),
'bucket' => env('S3_BUCKET'),
],

The other solution我最终选择的是:

's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET_KEY'),
'region' => Aws\Common\Enum\Region::OREGON,
'bucket' => 'app-images',
],

这些区域可以在 S3 GitHub Repo 上找到.

class Region extends Enum
{
const US_EAST_1 = 'us-east-1';
const VIRGINIA = 'us-east-1';
const NORTHERN_VIRGINIA = 'us-east-1';
const US_WEST_1 = 'us-west-1';
const CALIFORNIA = 'us-west-1';
const NORTHERN_CALIFORNIA = 'us-west-1';
const US_WEST_2 = 'us-west-2';
const OREGON = 'us-west-2';
const EU_WEST_1 = 'eu-west-1';
const IRELAND = 'eu-west-1';
const LONDON = 'eu-west-2';

const EU_CENTRAL_1 = 'eu-central-1';
const FRANKFURT = 'eu-central-1';
const AP_SOUTHEAST_1 = 'ap-southeast-1';
const SINGAPORE = 'ap-southeast-1';
const AP_SOUTHEAST_2 = 'ap-southeast-2';
const SYDNEY = 'ap-southeast-2';
const AP_NORTHEAST_1 = 'ap-northeast-1';
const TOKYO = 'ap-northeast-1';
const SA_EAST_1 = 'sa-east-1';
const SAO_PAULO = 'sa-east-1';
const CN_NORTH_1 = 'cn-north-1';
const BEIJING = 'cn-north-1';
const US_GOV_WEST_1 = 'us-gov-west-1';
const GOV_CLOUD_US = 'us-gov-west-1';
}

5 年后更新每条评论

现在我原来的方法又起作用了。我忘记了它什么时候开始工作的,但你就可以了。

文件系统.php

's3' => [
'driver' => 's3',
'key' => env('S3_KEY'),
'secret' => env('S3_SECRET'),
'region' => env('S3_REGION'),
'bucket' => env('S3_BUCKET'),
],

.env

S3_REGION=us-east-1

看起来他们删除了 Region.php 文件。今天,2020 年 6 月,S3Client.php文件是我可以在他们的存储库中找到的对区域的唯一引用。

关于Laravel 的文件系统与 s3 使用错误的 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29436790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com