Laravel 5.1 AWS S3 Flysytem:AWS HTTP错误:cURL错误6:无法解析主机名

时间:2015-06-13 16:54:16

标签: curl file-upload amazon-s3 laravel-5 host

我在我的本地环境中,即将使用Laravel 5.1 Flysystem / Filesystem将文件上传到AWS s3。

所有设置均已完成。我创建了一个测试表单,我正在尝试上传文件。当我按下提交按钮时,我绝对得到了这个,只有太可爱的错误:

{!! 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() !!}

Sooo ......我哪里出错了? 这是我的代码:

表格/视图

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

控制器商店方法

'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,
        ],

DATABASE CONFIG

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',
        ],
    ],
];

CONFIG / FILESYSTEMS.PHP

# Commands to pass into subprocess (each command is separated by a newline) 
commands = (
    "command1\n" +
    "command2\n"
)


# Your process
py_process = subprocess.Popen(*yourprocess_here*, stdin=PIPE, shell=True)

# Feed process the needed input
py_process.communicate(input=commands)

# Terminate when finished
py_process.terminate()

1 个答案:

答案 0 :(得分:7)

典型。保罗罗宾逊在阅读this article后意识到出了什么问题。

我已将s3区域设置为Activity。虽然我的区域肯定是Frankfurt,但我需要将其Frankfurt称为eu-central-1中的s3 region

之后,我可以继续修复config/filesystems.php方法中的下一个错误。

<强> WRONG

Storage::put()

<强> CORRECT

 Storage::put(
        'resource-'.$resource->id,
         $resource
 );

希望这可以帮助别人。有一个了不起的一天/晚/等。