softsmart/awss3

Simple AWSS3 implementation

1.0.4 2020-04-28 06:33 UTC

This package is auto-updated.

Last update: 2024-09-28 16:03:54 UTC


README

Software License

A simple AWS S3 GET, PUT, DELETE implementation in PHP using AWS Rest interface

Install

Via Composer

$ composer require softsmart/awss3

Usage


$object = new AWSS3();

$awsAccessKeyId = "MyAwsAccessKeyId";
$awsSecretAccessKey = "My/AwsSecret/Access/Key";
$bucketName = "MyBucketName";
$region = "us-east-2";

// GET an object
$return = $object->get('/dog.png', $awsAccessKeyId, $awsSecretAccessKey, $bucketName, $region);

if ($return["httpCode"] == 200) {
    file_put_contents(dirname(__FILE__)."/dog.png", $return["content"]);
    print "<img src=\"dog.png\">";
}


// PUT an object
$return = $object->put(dirname(__FILE__)."/dog.png", "/dog.png", $awsAccessKeyId, $awsSecretAccessKey, $bucketName, $region);


// DELETE an object
$return = $object->delete('/dog.png', $awsAccessKeyId, $awsSecretAccessKey, $bucketName, $region);
    

Testing

$ phpcs -c phpunit.xml

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Credits

License

GNU GENERAL PUBLIC LICENSE. Please see License File for more information.

Questions

Q: Why not just use their SDK?

A: Its probably best but the SDK is for all Amazon products. It seems like overkill if all you want to do is add and delete files to an S3 bucket (eg, for remote images).