php - S3 Bucket Amazon issue -
1) have upload form
2) uploads file local storage move_uploaded_file.
3) uses zend putobject function move file s3 object.
everything works ok till have file size of around 30mb 40 mb. problem when try uploading larger files 80 mb, 100 mb or so, file moving s3 takes ages complete upload. code this:
$orginalpath = application_path."/../storage/".$filename; move_uploaded_file($data['files']['tmp_name'], "$orginalpath"); $s3 = new zend_service_amazon_s3($accesskey, $secretkey); $s3->putobject($path, file_get_contents($orginalpath), array(zend_service_amazon_s3::s3_acl_header =>zend_service_amazon_s3::s3_acl_public_read)); can how handle large files move tried using streamwrapper this
$s3->registerstreamwrapper("s3"); file_put_contents("s3://my-bucket-name/orginal/$filename", file_get_contents($orginalpath)); but no luck, take same long time move file.
hence, there efficient way move file s3 bucket?
the answer worker process. can start php worker script via php cli on server boot, perhaps gearmanclient php extension , gearman server running on box. queue background job upload file s3 while main site php code returns success after issuing job , file happily uploads in background while foreground site continues on it's merry way. way of doing making server of task while main site remains utilization free of process. doing now. works well.
Comments
Post a Comment