2015-04-03 31 views
5

我正在使用Laravel的Filesystem在s3上存儲項目,並且我收到了錯誤的URL。Laravel的文件系統與s3使用了錯誤的網址

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 

此URL

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

應該

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

配置/ 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 
+0

也許'S3_REGION = s3-website-us-east-1' ...? – 2015-04-03 21:52:57

+0

是的,我試過它給了我'mybucket.s3.s3-website-us-east-1.amazonaws.com' – whoacowboy 2015-04-03 21:57:16

+1

正如在這裏添加的,刪除區域的解決方案爲我工作:http://laravel.io/forum/04-03-2015-filesystem-with-s3-giving-me-the-wrong-s3-url – 2015-04-21 02:32:14

回答

19

我終於找到了這兩個答案。

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', 
], 

的區域可以在A3 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'; 
} 
+0

我有相同的大壩問題,像2小時,我有沒有想法爲什麼這樣的事情是如此難以找到,這麼多thanx這個 – ctf0 2016-01-24 20:54:03