I am using Laravel 5.0 and using "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
ie, sups is created bucket but not the image.
What is the mistake i am doing and how can i fix this
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.
the File::get
is simply getting the contents of a file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.