Skip to content

mrjgreen/s3multiupload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

s3multiupload

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'])));
    
    }

About

s3multiupload is a tiny php object wrapper for aws s3clilent exposing a few simple methods for creating and signing multipart uploads - use for direct upload to s3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages