执行“ListObjects”时出错 “https://s3.your-region.amazonaws.com/your-bucket?prefix=abc%2F1468895496.jpg%2F&max-keys=1&encoding-type=url”; AWS HTTP错误:cURL错误6:无法解析主机: s3.your-region.amazonaws.com(见 http://curl.haxx.se/libcurl/c/libcurl-errors.html)
<?php
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');
}
答案 0 :(得分:2)
我认为你没有在config/filesystems.php
中设置配置,因为your-region
,your-bucket
等是默认值。
在此部分进行更改,确保密钥,密码,区域和存储桶已填满。
'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',
],
],