php - uploading posted file to amazon s3 -


i'm trying upload file amazon s3 via laravel 4.

after user submit form, file passed function need use amazon php sdk , upload file amazon s3 bucket.

but how upload file straight away amazon s3 without saving file onto server.

my current code looks this,

private function uploadvideo($vid){      $file = $vid;      $filename =  $file->getclientoriginalname();      if (!class_exists('s3'))require_once('s3.php');     if (!defined('awsaccesskey')) define('awsaccesskey', '123123123');     if (!defined('awssecretkey')) define('awssecretkey', '123123123');     $s3 = new s3(awsaccesskey, awssecretkey);     $s3->putbucket("mybucket", s3::acl_public_read);      $s3->putobject($vid, "mybucket",$filename , s3::acl_public_read);   } 

grab official sdk http://docs.aws.amazon.com/aws-sdk-php/latest/index.html

this example uses http://docs.aws.amazon.com/aws-sdk-php/latest/class-aws.s3.s3client.html#_upload

require('aws.phar'); use aws\s3\s3client; use aws\common\enum\region;  // instantiate s3 client aws credentials , desired aws region $client = s3client::factory(array(   'key'    => 'key here',   'secret' => 'secret here',   'region' => region::ap_southeast_2 // need change or remove ));  $result = $client->upload(   'bucket here',   'object key here',   'string of file here',   'public-read' // public access acl ); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -