2016-04-29 26 views
0

filesystems.phpファイルを使用してS3を設定しました。 私はこのエラーが発生したバケツにコンテンツを配置しよう:LaravelのS3エンドポイントを変更

Encountered a permanent redirect while requesting https://s3-us-west-2.amazonaws.com/MYBUCKET... Are you sure you are using the correct region for this bucket? 

私はその後、URLをアクセスもしようと、私はこのメッセージを得る:

:私が得る同じページで

The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. 

<Endpoint>s3.amazonaws.com</Endpoint> 

次にURLから地域を削除するにはどうすればいいですか?Laravelはを生成しますか?

+0

私はあなたがS3ファイルシステムドライバーのために使用しているパッケージを知っているかもしれませんか? – Praveesh

+0

league/flysystem-aws-s3-v3〜1.0 –

答えて

1

あなたはそのような顧客サービス・プロバイダーを作成することができます

use Illuminate\Support\ServiceProvider; 
use Aws\S3\S3Client; 
use League\Flysystem\AwsS3v3\AwsS3Adapter; 
use League\Flysystem\Filesystem; 
use Aws\Laravel\AwsServiceProvider; 
use Storage; 

class AwsS3ServiceProvider extends ServiceProvider 
{ 

    /** 
    * Perform post-registration booting of services. 
    * 
    * @return void 
    */ 
    public function boot() 
    { 
     Storage::extend('s3', function($app, $config) { 
      $client = new S3Client([ 
       'credentials' => [ 
        'key' => $config['key'], 
        'secret' => $config['secret'], 
       ], 
       'region' => $config['region'], 
       'version' => $config['version'], 
       'endpoint' => $config['endpoint'], 
       'ua_append' => [ 
        'L5MOD/' . AwsServiceProvider::VERSION, 
       ], 
      ]); 

      return new Filesystem(new AwsS3Adapter($client, $config['bucket_name'])); 
     }); 
    } 

    /** 
    * Register bindings in the container. 
    * 
    * @return void 
    */ 
    public function register() 
    { 
     // 
    } 
} 

をし、同様にconfig/filesystems.phpendpoint変数を追加します。

's3' => [ 
    'driver' => 's3', 
    'key' => env('AWS_KEY'), 
    'secret' => env('AWS_SECRET'), 
    'region' => env('AWS_REGION'), 
    'version' => 'latest', 
    'endpoint' => env('AWS_ENDPOINT'), 
    'bucket_name' => env('AWS_BUCKET_NAME') 
] 

how to extend Storage facadeの詳細を取得するためにdocsを見てください。

0

特定のバケットはAWSで作成されないため、AWSでバケットを作成し、ファイルシステムの設定で同じバケットを使用してください。問題は解決されます。

関連する問題