Uncategorized
By Acty, January 28, 2014
PHP AWS S3 Integration Library provides an easiest way to integrate AWS S3 in a PHP project. Using this library you can use the S3(Simple Storage Service by Amazon) Bucket as a storage for user uploaded files in your project.
Using uploaded_file_to_s3() function, the uploaded file will store on same relative location in an S3 Bucket instead of web-server.
//Normal code to upload a file on web-server move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); //Change to uploaded_file_to_s3($_FILES["file"], "uploads", true);
Using site_url_s3() function, File will be referenced from same relative location from S3 Bucket instead of web-server.
//Normal code to refer a file on web-server <a href="uploads/myphoto.jpg">Download/View</a> //Change to <a href="<?php echo site_url_s3(" uploads="">">Download/View</a>
Upload a file manually from the web-server to an S3 bucket
//Upload uploads/myphoto.jpg file to S3 Bucket. uploaded_file_to_s3_manually("uploads", "myphoto.jpg", "uploads", true);
Copy a S3 file from one Bucket to another or in same Bucket
//Copy S3 File copy_s3($source, $destination);
To create a S3 Bucket in your AWS account
//Create a S3 Bucket create_bucket($bucket_name);
I will be more then happy to help and provide support you through any problems you may have, or and features/suggestions that you want to implement. Just send me an email or leave a comment.
Note: AWS/S3 and Codeigniter are the Trademarks of their respective owners.