joegreen0991 / s3multiupload
There is no license information available for the latest version (dev-master) of this package.
A class for uploading direct to s3 with chunked uploads
dev-master
2013-08-13 09:40 UTC
Requires
This package is not auto-updated.
Last update: 2024-11-18 14:42:40 UTC
README
Full example for uploading directly to Amazon S3 with plupload and chunked uploads https://github.com/joegreen0991/chunkedPluploadToS3Example
// We need to give our class an instance of the S3Client $s3Client = \Aws\Common\Aws::factory(array( 'key' => S3_KEY, 'secret' => S3_SECRET, 'region' => S3_REGION ))->get('s3'); // We also need to pass in a storage handler, so we can remember the multipart_id between requests - use native sessions, or roll your own $keyStorage = new S3MultiUpload\KeyStorage\NativeSession; // Create our object to manage the signing server side - we generate the url and all the params, but hand it back to the client to send the actual data $s3 = new S3MultiUpload\Client($s3Client, $keyStorage); switch ($_REQUEST['action']) { case 'sign' : if(empty($_REQUEST['uploadId'])){ // This is a new upload $filename = $_REQUEST['name']; // Using original file name, but you could use randomly generated names etc... $multipart_id = $s3->createMultipart(S3_BUCKET, $filename); }else{ $multipart_id = $_REQUEST['uploadId']; } die(json_encode($s3->signMultipart($multipart_id, $_REQUEST['chunk'], array('Content-Type' => 'application/octet-stream')))); case 'complete' : die(json_encode($s3->completeMultipart($_REQUEST['uploadId']))); }