2017 © Pedro Peláez
 

library s3

A simple aws s3 class

image

buuum/s3

A simple aws s3 class

  • Tuesday, July 11, 2017
  • by buuum
  • Repository
  • 3 Watchers
  • 5 Stars
  • 7,056 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 11 Versions
  • 9 % Grown

The README.md

Amazon S3 (REST) client for PHP

Packagist license, (*1)

Install

System Requirements

You need PHP >= 5.5.0 to use Buuum\S3 but the latest stable version of PHP is recommended., (*2)

Composer

Buuum\S3 is available on Packagist and can be installed using Composer:, (*3)

composer require buuum/s3

Manually

You may use your own autoloader as long as it follows PSR-0 or PSR-4 standards. Just put src directory contents in your vendor directory., (*4)

CONSTANTS

const ACL_PRIVATE = 'private';
const ACL_PUBLIC_READ = 'public-read';
const ACL_PUBLIC_READ_WRITE = 'public-read-write';
const ACL_AUTHENTICATED_READ = 'authenticated-read';

const STORAGE_CLASS_STANDARD = 'STANDARD';
const STORAGE_CLASS_RRS = 'REDUCED_REDUNDANCY';
const STORAGE_CLASS_STANDARD_IA = 'STANDARD_IA';

USAGE

INITIALIZE

S3::setAuth($awsAccessKey, $awsSecretKey);

SET and GET default bucket

S3::setBucket($bucket);
S3::getBucket();

SET urls

$urls = [
    'http'  => 'http://s3-eu-west-1.amazonaws.com/bucket',
    'https' => 'https://s3-eu-west-1.amazonaws.com/bucket'
];
S3::setUrls($urls);

SET ACL AND STORAGE (Optional, default acl = S3::ACL_PUBLIC_READ, storage = S3::STORAGE_CLASS_STANDARD)

S3::setAcl(S3::ACL_PRIVATE);
S3::setStorage(S3::STORAGE_CLASS_STANDARD);

UPLOADING OBJECTS

Put an object from $_FILES, (*5)

S3::putObject($_FILES['filename']['tmp_name'], $_FILES['filename']['name']);

Put an object from string, (*6)

S3::putObjectString(file_get_contents('bg.jpg'), 'bg.jpg');

Put an object from url, (*7)

$url = 'https://www.enterprise.es/content/dam/ecom/utilitarian/emea/business-rentals/business-rental-band.jpg.wrend.1280.720.jpeg';
S3::putObjectUrl($url, 'car.jpg');

Set headers on put objects 1.- as parameter, (*8)

$headers = [
    'Cache-Control' => 'max-age=2592000',
    'Expires'       => 2592000,
];
S3::putObjectUrl($url, 'car.jpg', $headers);

2.- as defaultheaders, (*9)

$headers = [
    'Cache-Control' => 'max-age=2592000',
    'Expires'       => 2592000,
];
S3::setDefaultHeaders($headers);

Put response, (*10)

array(4) {
  ["code"]=> int(200)
  ["error"]=>  bool(false)
  ["message"]=>  string(0) ""
  ["url"]=>
  array(3) {
    ["default"]=>
    string(53) "https://bucket.s3.amazonaws.com/20130726_173253.jpg"
    ["http"]=>
    string(62) "http://s3-eu-west-1.amazonaws.com/bucket/20130726_173253.jpg"
    ["https"]=>
    string(63) "https://s3-eu-west-1.amazonaws.com/bucket/20130726_173253.jpg"
  }
}

RETRIEVING OBJECTS

Get an object:, (*11)

$response = S3::getObject('bg.jpg',$bucketName);
file_put_contents('bg.jpg', $response->message);

DELETING OBJECTS

Delete an object:, (*12)

S3::deleteObject('bg.jpg',$bucketName);

Delete an object from url:, (*13)

S3::deleteObjectUrl('https://s3-eu-west-1.amazonaws.com/bucket/20130726_173253.jpg');

BUCKETS

Get a list of buckets:, (*14)

$buckets = S3::listBuckets();

Create a bucket:, (*15)

S3::putBucket($bucketName);

Delete an empty bucket:, (*16)

S3::deleteBucket($bucketName);

FILES

Get a list of files in bucket, (*17)

S3::listFiles($bucketName);

LICENSE

The MIT License (MIT), (*18)

Copyright (c) 2016, (*19)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*20)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*21)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*22)

The Versions

11/07 2017

dev-master

9999999-dev https://github.com/buuum/S3

A simple aws s3 class

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Alfons Martinez

s3 aws s3

11/07 2017

v1.0.0

1.0.0.0 https://github.com/buuum/S3

A simple aws s3 class

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Alfons Martinez

s3 aws s3

29/12 2016

v0.0.9

0.0.9.0 https://github.com/buuum/S3

A simple aws s3 class

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Alfons Martinez

s3 aws s3

14/12 2016

v0.0.8

0.0.8.0 https://github.com/buuum/S3

A simple aws s3 class

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Alfons Martinez

s3 aws s3

28/10 2016

v0.0.7

0.0.7.0 https://github.com/buuum/S3

A simple aws s3 class

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Alfons Martinez

s3 aws s3

28/10 2016

v0.0.6

0.0.6.0 https://github.com/buuum/S3

A simple aws s3 class

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Alfons Martinez

s3 aws s3

27/10 2016

v0.0.5

0.0.5.0 https://github.com/buuum/S3

A simple aws s3 class

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Alfons Martinez

s3 aws s3

24/08 2016

v0.0.4

0.0.4.0 https://github.com/buuum/S3

A simple aws s3 class

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Alfons Martinez

s3 aws s3

24/08 2016

v0.0.3

0.0.3.0 https://github.com/buuum/S3

A simple aws s3 class

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Alfons Martinez

s3 aws s3

13/07 2016

v0.0.2

0.0.2.0 https://github.com/buuum/S3

A simple aws s3 class

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Alfons Martinez

s3 aws s3

02/06 2016

v0.0.1

0.0.1.0 https://github.com/buuum/S3

A simple aws s3 class

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Alfons Martinez

s3 aws s3