【发布时间】:2016-01-05 03:09:34
【问题描述】:
对于 Laravel 5.2 的 s3 驱动程序有问题。我得到的错误是:
Found 1 error while validating the input provided for the HeadObject operation:
[Key] must be at least 1 characters long. Value provided is 0 characters long.
我正在使用 Laravel 文档中所述的联盟飞行系统 V3。当我按照堆栈跟踪并开始转储变量时,“键”值始终为空,但我已将其全部设置在我的配置文件中。
这是我的堆栈跟踪中的顶行
in Validator.php line 38
at Validator->validate('HeadObject', object(StructureShape), array('Bucket' => 'monstervsl', 'Key' => '', '@http' => array())) in Middleware.php line 77
at Middleware::Aws\{closure}(object(Command), null) in S3Client.php line 710
at S3Client::Aws\S3\{closure}(object(Command), null) in S3Client.php line 729
at S3Client::Aws\S3\{closure}(object(Command), null) in Middleware.php line 53
at Middleware::Aws\{closure}(object(Command), null) in SSECMiddleware.php line 59
at SSECMiddleware->__invoke(object(Command)) in AwsClient.php line 208
如您所见,它从我的配置中获取存储桶,但不是空的键。
这是我的filesystem.php 文件
's3' => [
'driver' => 's3',
// 'key' => env('S3_KEY'),
// 'secret' => env('S3_SECRET'),
'key' => '8tfnxo8abgn7voaex8rgv', // <- Not my real key
'secret' => 'aw7btx49wXNF7AGWV', // <- not my real secret
'region' => 'eu-west-1',
'bucket' => 'monstervsl',
],
这是我的控制器,它相当简单,我认为放置内容的东西不相关,但还是添加了它
// Write the contents to a new file on disk
$view = view('iframe')->with('json', $video->toJson());
$contents = $view->render();
$token = '12345';
$filePath = public_path() .'/iframes/' . $token . '.html';
file_put_contents($filePath, $contents);
Storage::disk('s3')->put('/', file_get_contents($filePath));
【问题讨论】:
标签: php laravel amazon-s3 laravel-5