我在我的本地环境中,即将使用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()
答案 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
);
希望这可以帮助别人。有一个了不起的一天/晚/等。