【问题标题】:Laravel AWS S3 Upload photo error (Region error?)Laravel AWS S3上传照片错误(区域错误?)
【发布时间】:2016-11-21 18:26:08
【问题描述】:

执行“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');
    }

【问题讨论】:

标签: php laravel amazon-web-services amazon-s3


【解决方案1】:

我认为您没有在config/filesystems.php 中设置配置,因为your-regionyour-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',
    ],

],

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-02
    • 2011-10-13
    • 2012-03-30
    • 1970-01-01
    • 2017-08-10
    • 2012-05-28
    • 1970-01-01
    相关资源
    最近更新 更多