gpt4 book ai didi

curl - Laravel 5.1 AWS S3 Flysytem : AWS HTTP error: cURL error 6: Couldn't resolve host name

转载 作者:行者123 更新时间:2023-12-01 22:28:23 27 4
gpt4 key购买 nike

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

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

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...我哪里出错了? 这是我的代码:

表单/ 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 存储方法

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

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

最佳答案

典型。阅读后意识到问题所在 this article作者:保罗·罗宾逊。

我已将我的 s3 区域设置为 Frankfurt。虽然我的区域确实是 Frankfurt,但我需要将其称为 eu-central-1 作为我的 s3 regionconfig/filesystems.php 中。

之后,我可以继续修复 Storage::put() 方法中的下一个错误。

错误

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

正确

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

希望这可以帮助其他人。祝你度过美好的一天/夜晚/等等。

关于curl - Laravel 5.1 AWS S3 Flysytem : AWS HTTP error: cURL error 6: Couldn't resolve host name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30821208/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com