file upload - Laravel 5.1 AWS S3 Flysytem: AWS HTTP error: cURL error 6: Couldn't resolve host name -
i'm on local environment , enable file uploading aws s3, using laravel 5.1 flysystem/filesystem.
all setup has been done. have created test form, , i'm trying upload file. when push submit button, absolutely, lovable error:
s3exception in wrappedhttphandler.php line 152: error executing "headobject" on "https://s3.frankfurt.amazonaws.com/bucketname/resource-6"; aws http error: curl error 6: couldn't resolve host name
sooo... have gone wrong? here code:
form / view
{!! form::open([ 'route' => 'resource-store', 'class' => 'uploadresource', 'files' => true ]) !!} {!! form::label('resource title') !!} {!! form::text('title', null, ['placeholder'=>'descriptive title']) !!} {!! form::label('your resource') !!} {!! form::file('resource', null) !!} {!! form::submit('create resource') !!} {!! form::close() !!}
controller store method
public function store(resourcerequest $request, $id) { /* store entry in db */ $resource = new resource(); $resource->title = $request->title; $resource->save(); /* process, validate & store image */ storage::put( 'resource-'.$resource->id, $resource ); /* success message */ session()->flash('message', $request->title . ' er lavet/uploadet!'); return redirect()->route('resource.index'); }
database config
'mysql' => [ 'driver' => 'mysql', 'host' => env('db_host', 'localhost'), 'database' => env('db_database', 'forge'), 'username' => env('db_username', 'forge'), 'password' => env('db_password', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'port' => 33060, ],
config/filesystems.php
return [ 'default' => 's3', 'cloud' => 's3', 'disks' => [ 'local' => [ 'driver' => 'local', 'root' => storage_path().'/app', ], 's3' => [ 'driver' => 's3', 'key' => env('aws_key'), 'secret' => env('aws_secret'), 'region' => env('aws_region'), 'bucket' => env('aws_bucket'), ], 'rackspace' => [ 'driver' => 'rackspace', 'username' => 'your-username', 'key' => 'your-key', 'container' => 'your-container', 'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/', 'region' => 'iad', ], ], ];
typical. realized wrong after reading this article paul robinson.
i had set s3 region frankfurt
. while region sure enough frankfurt
, needed refer eu-central-1
s3 region in config/filesystems.php
.
after go on fix next error in storage::put()
method.
wrong
storage::put( 'resource-'.$resource->id, $resource );
correct
storage::put( 'resource-'.$resource->id, file_get_contents($request->file('resource')) );
hope can others. have terrific day/night/etc.
Comments
Post a Comment