![]() |
Accessing Amazon S3 with PHP using Amazon AWS SDK
Amazon Simple Storage Service (S3) is a low-cost & high-availability storage service provided by Amazon Web Services. It's very efficient and cheap, it allows you to store as much as you want and there is no limit, you pay for what you use and you pay as you go, there is no commitment. You can check their service details and pricing at http://aws.amazon.com/s3/
In this article we'll look at accessing the service using PHP library provided by Amazon. Installing AWS PHP SDKThere are more than one way to install the SDK, you may use the one that suits you. Download and install from http://aws.amazon.com/sdkforphp. You can get it from GitHub Code:
# git clone git://github.com/amazonwebservices/aws-sdk-for-php.git AWSSDKforPHPCode:
# svn co http://svn.github.com/amazonwebservices/aws-sdk-for-php.git AWSSDKforPHPCode:
# pear channel-discover pear.amazonwebservices.comUsageLet's now go about looking at the usage of the SDK for some common operations on S3, I will not be able to list all here, but you may look the complete list of method at http://docs.amazonwebservices.com/AWSSDKforPHP/latest/ Listing Buckets Follow the simple example below to list all the buckets in your S3 account. Code: PHP
Listing Object in a Bucket List all the keys in a bucket, with and without specifying a prefix. Code: PHP
You can upload files of any size, you can set permissions of the file while uploading them. Code: PHP
You can download a file to the filesystem, or have it in the object (if it's a small file). Code: PHP
You can delete a single object or multiple objects from a S3 bucket. Code: PHP
|
| All times are GMT +5.5. The time now is 15:43. |