Examining Cloud Storage Options Part IV

iv ) Assessing API interconnectivity :

 You want a solid API that you and your team can work with, which handles all the basic functionality you need and integrates not only with your own existing platform, but the other members of the Cloud storage services platform as well.

To get an idea of how they work, let's take a quick look at the application of one such storage related API.

Here we have, aws_delete.php


// Include the AWS SDK using the Composer autoloader.
require 'vendor/autoload.php';

use Aws\S3\S3Client;

$s3 = S3Client::factory();

$bucket = '*** Your Bucket Name ***';
$keyname = '*** Your Object Key ***';

$result = $s3->deleteObject(array(
    'Bucket' => $bucket,
    'Key'    => $keyname
));

This bit of code deletes a specific object in a specific bucket in the AWS S3 service. It's a pretty simple bit of code, and that's because it relies on an API. So after the initial include on line four where it brings in autoload.php, it sets up to use the S3 client class.

Then on line eight it establishes an instance of that client class using the factory method.These are all part of the API.

Variables for bucket and key name are set up. Obviously, you would put your own bucket or container name there as well as the object key name.

Then, it's a simple matter of using the delete object function, again part of the API, on your created instance

You can explore Google cloud APIs, https://cloud.google.com/storage/docs/json_api/v1/

Reference : https://www.lynda.com/Cloud-Platform-tutorials/Assessing-API-interconnectivity/383929/432098-4.html

Comments