Question:
Error executing “ListObjects” on
“https://s3.your-region.amazonaws.com/your-bucket?prefix=abc%2F1468895496.jpg%2F&max-keys=1&encoding-type=url“;
AWS HTTP error: cURL error 6: Could not resolve host:
s3.your-region.amazonaws.com (see
http://curl.haxx.se/libcurl/c/libcurl-errors.html)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
namespace App\Http\Controllers; use Illuminate\Contracts\Filesystem\Filesystem; use App\Product; use Illuminate\Http\Request; class ProductController extends Controller { ... public function store(Request $request) { $image = $request->file('file'); $imageFileName = time() . '.' . $image->getClientOriginalExtension(); $s3 = \Storage::disk('s3'); $filePath = '/abc/' . $imageFileName; $s3->put($filePath, file_get_contents($image), 'public'); return redirect()->action('ProductController@index'); } |
Answer:
I think you havent set the config in config/filesystems.php
because the your-region
, your-bucket
etc is the default value.
Change at this section and make sure the key, secret, region and bucket are filled up.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
'disks' => [ 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), ], 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), 'visibility' => 'public', ], // s3 part is here 's3' => [ 'driver' => 's3', 'key' => 'your-key', 'secret' => 'your-secret', 'region' => 'ap-southeast-1', // this is the region setting 'bucket' => 'your-bucket', ], ], |