class S3


Located at : UKNOWVA_ROOT/components/com_community/libraries/storage/s3_lib.php

Constants

ACL_PRIVATE

ACL_PUBLIC_READ

ACL_PUBLIC_READ_WRITE

ACL_AUTHENTICATED_READ

Properties

static $useSSL

Methods

void
__construct(string $accessKey = null, string $secretKey = null, boolean $useSSL = true)

Constructor - if you're not using the class statically

static void
setAuth(string $accessKey, string $secretKey)

Set AWS access key and secret key

static array
listBuckets(boolean $detailed = false)

Get a list of buckets

static 
getBucket($bucket, $prefix = null, $marker = null, $maxKeys = null, $delimiter = null, $returnCommonPrefixes = false)

No description

static boolean
putBucket(string $bucket, constant $acl = self::ACL_PRIVATE, string $location = false)

Put a bucket

static boolean
deleteBucket(string $bucket)

Delete an empty bucket

static array
inputFile(string $file, mixed $md5sum = true)

Create input info array for putObject()

static array
inputResource(string $resource, integer $bufferSize, string $md5sum = '')

Create input array info for putObject() with a resource

static boolean
putObject(mixed $input, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = array(), array $requestHeaders = array())

Put an object

static boolean
putObjectFile(string $file, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = array(), string $contentType = null)

Put an object from a file (legacy function)

static boolean
putObjectString(string $string, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = array(), string $contentType = 'text/plain')

Put an object from a string (legacy function)

static mixed
getObject(string $bucket, string $uri, mixed $saveTo = false)

Get an object

static mixed
getObjectInfo(string $bucket, string $uri, boolean $returnInfo = true)

Get object information

static mixed
copyObject($srcBucket, $srcUri, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array())

Copy an object

static boolean
setBucketLogging(string $bucket, string $targetBucket, string $targetPrefix = null)

Set logging for a bucket

static array
getBucketLogging(string $bucket)

Get logging status for a bucket

static boolean
disableBucketLogging(string $bucket)

Disable bucket logging

static string
getBucketLocation(string $bucket)

Get a bucket's location

static boolean
setAccessControlPolicy(string $bucket, string $uri = '', array $acp = array())

Set object or bucket Access Control Policy

static mixed
getAccessControlPolicy(string $bucket, string $uri = '')

Get object or bucket Access Control Policy

static boolean
deleteObject(string $bucket, string $uri)

Delete an object

static string
getAuthenticatedURL(string $bucket, string $uri, integer $lifetime, boolean $hostBucket = false, boolean $https = false)

Get a query string authenticated URL

static object
getHttpUploadPostParams(string $bucket, string $uriPrefix = '', constant $acl = self::ACL_PRIVATE, integer $lifetime = 3600, integer $maxFileSize = 5242880, string $successRedirect = '201', array $amzHeaders = array(), array $headers = array(), boolean $flashVars = false)

Get upload POST parameters for form uploads

static array
createDistribution(string $bucket, boolean $enabled = true, array $cnames = array(), string $comment = '')

Create a CloudFront distribution

static array
getDistribution(string $distributionId)

Get CloudFront distribution info

static array
updateDistribution(array $dist)

Update a CloudFront distribution

static boolean
deleteDistribution(array $dist)

Delete a CloudFront distribution

static array
listDistributions()

Get a list of CloudFront distributions

static string
__getMimeType(string $file)

Get MIME type for file

static string
__getSignature(string $string)

Generate the auth string: "AWS AccessKey:Signature"

Details

at line 68
void __construct(string $accessKey = null, string $secretKey = null, boolean $useSSL = true)

Constructor - if you're not using the class statically

Parameters

string $accessKey Access key
string $secretKey Secret key
boolean $useSSL Enable SSL

Return Value

void

at line 82
static void setAuth(string $accessKey, string $secretKey)

Set AWS access key and secret key

Parameters

string $accessKey Access key
string $secretKey Secret key

Return Value

void

at line 94
static array listBuckets(boolean $detailed = false)

Get a list of buckets

Parameters

boolean $detailed Returns detailed bucket list when true

Return Value

array | false

at line 136
static getBucket($bucket, $prefix = null, $marker = null, $maxKeys = null, $delimiter = null, $returnCommonPrefixes = false)

Parameters

$bucket
$prefix
$marker
$maxKeys
$delimiter
$returnCommonPrefixes

at line 216
static boolean putBucket(string $bucket, constant $acl = self::ACL_PRIVATE, string $location = false)

Put a bucket

Parameters

string $bucket Bucket name
constant $acl ACL flag
string $location Set as "EU" to create buckets hosted in Europe

Return Value

boolean

at line 249
static boolean deleteBucket(string $bucket)

Delete an empty bucket

Parameters

string $bucket Bucket name

Return Value

boolean

at line 270
static array inputFile(string $file, mixed $md5sum = true)

Create input info array for putObject()

Parameters

string $file Input file
mixed $md5sum Use MD5 hash (supply a string if you want to use your own)

Return Value

array | false

at line 289
static array inputResource(string $resource, integer $bufferSize, string $md5sum = '')

Create input array info for putObject() with a resource

Parameters

string $resource Input resource to read from
integer $bufferSize Input byte size
string $md5sum MD5 hash to send (optional)

Return Value

array | false

at line 311
static boolean putObject(mixed $input, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = array(), array $requestHeaders = array())

Put an object

Parameters

mixed $input Input data
string $bucket Bucket name
string $uri Object URI
constant $acl ACL constant
array $metaHeaders Array of x-amz-meta-* headers
array $requestHeaders Array of request headers or content type as a string

Return Value

boolean

at line 387
static boolean putObjectFile(string $file, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = array(), string $contentType = null)

Put an object from a file (legacy function)

Parameters

string $file Input file path
string $bucket Bucket name
string $uri Object URI
constant $acl ACL constant
array $metaHeaders Array of x-amz-meta-* headers
string $contentType Content type

Return Value

boolean

at line 403
static boolean putObjectString(string $string, string $bucket, string $uri, constant $acl = self::ACL_PRIVATE, array $metaHeaders = array(), string $contentType = 'text/plain')

Put an object from a string (legacy function)

Parameters

string $string Input data
string $bucket Bucket name
string $uri Object URI
constant $acl ACL constant
array $metaHeaders Array of x-amz-meta-* headers
string $contentType Content type

Return Value

boolean

at line 416
static mixed getObject(string $bucket, string $uri, mixed $saveTo = false)

Get an object

Parameters

string $bucket Bucket name
string $uri Object URI
mixed $saveTo Filename or resource to write to

Return Value

mixed

at line 448
static mixed getObjectInfo(string $bucket, string $uri, boolean $returnInfo = true)

Get object information

Parameters

string $bucket Bucket name
string $uri Object URI
boolean $returnInfo Return response information

Return Value

mixed | false

at line 474
static mixed copyObject($srcBucket, $srcUri, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array())

Copy an object

Parameters

$srcBucket
$srcUri
$bucket
$uri
$acl
$metaHeaders
$requestHeaders

Return Value

mixed | false

at line 506
static boolean setBucketLogging(string $bucket, string $targetBucket, string $targetPrefix = null)

Set logging for a bucket

Parameters

string $bucket Bucket name
string $targetBucket Target bucket (where logs are stored)
string $targetPrefix Log prefix (e,g; domain.com-)

Return Value

boolean

at line 565
static array getBucketLogging(string $bucket)

Get logging status for a bucket

This will return false if logging is not enabled. Note: To enable logging, you also need to grant write access to the log group

Parameters

string $bucket Bucket name

Return Value

array | false

at line 590
static boolean disableBucketLogging(string $bucket)

Disable bucket logging

Parameters

string $bucket Bucket name

Return Value

boolean

at line 601
static string getBucketLocation(string $bucket)

Get a bucket's location

Parameters

string $bucket Bucket name

Return Value

string | false

at line 624
static boolean setAccessControlPolicy(string $bucket, string $uri = '', array $acp = array())

Set object or bucket Access Control Policy

Parameters

string $bucket Bucket name
string $uri Object URI
array $acp Access Control Policy Data (same as the data returned from getAccessControlPolicy)

Return Value

boolean

at line 682
static mixed getAccessControlPolicy(string $bucket, string $uri = '')

Get object or bucket Access Control Policy

Parameters

string $bucket Bucket name
string $uri Object URI

Return Value

mixed | false

at line 738
static boolean deleteObject(string $bucket, string $uri)

Delete an object

Parameters

string $bucket Bucket name
string $uri Object URI

Return Value

boolean

at line 762
static string getAuthenticatedURL(string $bucket, string $uri, integer $lifetime, boolean $hostBucket = false, boolean $https = false)

Get a query string authenticated URL

Parameters

string $bucket Bucket name
string $uri Object URI
integer $lifetime Lifetime in seconds
boolean $hostBucket Use the bucket name as the hostname
boolean $https Use HTTPS ($hostBucket should be false for SSL verification)

Return Value

string

at line 784
static object getHttpUploadPostParams(string $bucket, string $uriPrefix = '', constant $acl = self::ACL_PRIVATE, integer $lifetime = 3600, integer $maxFileSize = 5242880, string $successRedirect = '201', array $amzHeaders = array(), array $headers = array(), boolean $flashVars = false)

Get upload POST parameters for form uploads

Parameters

string $bucket Bucket name
string $uriPrefix Object URI prefix
constant $acl ACL constant
integer $lifetime Lifetime in seconds
integer $maxFileSize Maximum filesize in bytes (default 5MB)
string $successRedirect Redirect URL or 200 / 201 status code
array $amzHeaders Array of x-amz-meta-* headers
array $headers Array of request headers or content type as a string
boolean $flashVars Includes additional "Filename" variable posted by Flash

Return Value

object

at line 834
static array createDistribution(string $bucket, boolean $enabled = true, array $cnames = array(), string $comment = '')

Create a CloudFront distribution

Parameters

string $bucket Bucket name
boolean $enabled Enabled (true/false)
array $cnames Array containing CNAME aliases
string $comment Use the bucket name as the hostname

Return Value

array | false

at line 860
static array getDistribution(string $distributionId)

Get CloudFront distribution info

Parameters

string $distributionId Distribution ID from listDistributions()

Return Value

array | false

at line 886
static array updateDistribution(array $dist)

Update a CloudFront distribution

Parameters

array $dist Distribution array info identical to output of getDistribution()

Return Value

array | false

at line 915
static boolean deleteDistribution(array $dist)

Delete a CloudFront distribution

Parameters

array $dist Distribution array info identical to output of getDistribution()

Return Value

boolean

at line 937
static array listDistributions()

Get a list of CloudFront distributions

Return Value

array

at line 1057
static string __getMimeType(string $file)

Get MIME type for file

Parameters

string $file &$file File path

Return Value

string

at line 1105
static string __getSignature(string $string)

Generate the auth string: "AWS AccessKey:Signature"

Parameters

string $string String to sign

Return Value

string