An article about Amazon s3 Integration
Finding the way to store ,distribute and manage the data are big challenge. We know that the building and maintaining our own storage repository is expensive and time consuming. Amazon Simple Storage Service (amazon-s3 is the better way) provides developers and IT teams with secure, durable, highly-scalable object storage
Advantages of amazon-s3
- Easy to use
- Simple web services interface
- Store and retrieve any amount of data from anywhere on the web
- Pay only for what you use. No no minimum fee and set up fee
- No need to worry of losing data because it automatically make copy of an object on multiple devices on multiple facility
- Flexible to control access permission of data using Access control list, identity of access management policy and bucket policy
- Help to secure upload and download data with SSL crypted end points.
Buckets
Amazon S3 stores data as objects within resources called "buckets."
- We can control access to the bucket
- We can choose the AWS region
An object consists of a file and optionally any metadata that describes that file. We can also set permissions on the object as well as any metadata.
For getting start with Amazon s3, please go to the link http://aws.amazon.com/s3/ and sign up.
For programmatic access to Amazon S3 AWS SDKs and the AWS Mobile SDK are used. In an drupal we have a module called Amazon S3. For download this module please go to the link https://www.drupal.org/project/amazon_s3. s3.inc file contains all s3 functions defined in Amazon.
Note : To set these API key you register an Amazon account(http://aws.amazon.com/s3/) and generated API keys
Firstly we need to create buckets to upload files, we can create buckets programatically like this
Firstly need to create an obejct of amazon s3 like this
$s3 = new S3($aws_access_key, $aws_secret_key);
$aws_access_key, $aws_secret_key are API keys that can generate from our amazon s3 account
Then,
$s3 = amazon_s3_get_instance();
return $s3->putBucket($bucket_name, $access_control);
To list buckets
$s3->listBuckets();
To delete buckets
$s3->deleteBucket($bucket);
To upload a file in to the amazon s3 using below code
$input = S3::inputFile('filepath');
S3::putObject($input, 'bucket_name', 'filepath', S3::ACL_PUBLIC_READ);