I am using Laravel 5.0 and using "aws/aws-sdk-php-laravel": "~2.0"
我正在使用Laravel 5.0并使用“aws / aws-sdk-php-laravel”:“~2.0”
Here is my script to upload the image
这是我上传图片的脚本
$s3 = App::make('aws')->get('s3');
$s3->putObject(array(
'Bucket' => 'greenhoppingbucket',
'Key' => 'sups',
'Body' => Input::file('file'),
));
After the execution only the key is uploaded in the s3 bucket
执行后,只将密钥上传到s3存储桶中
i.e., sups is created bucket but not the image.
即,sups是创建桶而不是图像。
What is the mistake i am doing and how can i fix this
我正在做的错误是什么,我该如何解决这个问题
1 个解决方案
#1
1
try this:
尝试这个:
$s3 = App::make('aws')->get('s3');
$s3->putObject(array(
'Bucket' => 'greenhoppingbucket',
'Key' => 'sups',
'Body' => File::get((string)Input::file('file')),
));
dont forget to add use File;
别忘了添加使用文件;
when you do 'Body' => Input::file('file'), you bassiclly putting the temp path into the body instead of the content of the file.
当你执行'Body'=> Input :: file('file')时,你可以将临时路径放入正文而不是文件内容。
the File::get
is simply getting the contents of a file
File :: get只是获取文件的内容
#1
1
try this:
尝试这个:
$s3 = App::make('aws')->get('s3');
$s3->putObject(array(
'Bucket' => 'greenhoppingbucket',
'Key' => 'sups',
'Body' => File::get((string)Input::file('file')),
));
dont forget to add use File;
别忘了添加使用文件;
when you do 'Body' => Input::file('file'), you bassiclly putting the temp path into the body instead of the content of the file.
当你执行'Body'=> Input :: file('file')时,你可以将临时路径放入正文而不是文件内容。
the File::get
is simply getting the contents of a file
File :: get只是获取文件的内容