Functions

Function Description
_getRackspaceURL Checks to see if the bucket is CDN enabled, if it is we use the CDN URL, otherwise the private URL.
copyFile Copies a file from one container/location to another container/location.
createContainer Creates a new container/bucket.
createFile Creates a new file in the given container.
createFolder Creates a new folder in the given container.
deleteContainer Deletes a container/bucket.
deleteFile Deletes a file from the given container.
getAuthenticatedFileURL Returns a URL that is valid for a limited amount of time to a private file.
getCloudFrontDistributions Returns an array of distributions.
getContainer Lists the contents of a container/bucket.
getFile Returns a file from the given container.
getFolder Returns the folder "contents" from a container.
getRackspaceToken Gets a new access token for the Rackspace Cloud Files API.
getS3BucketExists Returns true if a bucket of the specified name already exists.
getS3BucketPage Returns a page of contents of an Amazon S3 bucket.
getS3BucketRegion Returns the proper region for the specified bucket.
invalidateCache Invalidates the CloudFront cache for a given pointer.
listContainers Lists containers/buckets that are available in this cloud account.
makeFilePublic Makes a file readable to the public.
resetCache Clears the bigtree_caches table of container data and resets it with new data.
setupAmazon Sets up the S3/CloudFront clients for Amazon calls.
uploadFile Creates a new file in the given container.
callRackspace cURL wrapper for Rackspace.

_getRackspaceURL

Checks to see if the bucket is CDN enabled, if it is we use the CDN URL, otherwise the private URL.

Return Value: A URL

_getRackspaceURL($container, $pointer)
Parameter Description
$container Container name
$pointer File pointer

copyFile

Copies a file from one container/location to another container/location.
Rackspace Cloud Files ignores "access" — public/private is controlled through the container only.

Return Value: The URL of the file if successful.

copyFile($source_container, $source_pointer, $destination_container, $destination_pointer, $public = false)
Parameter Description
$source_container The container the file is stored in.
$source_pointer The full file path inside the container.
$destination_container The container to copy the source file to.
$destination_pointer The full file path to store the copied file
$public true to make publicly accessible, defaults to false (this setting is ignored in Rackspace Cloud Files and is ignored in Amazon S3 if the bucket's policy is set to public)

createContainer

Creates a new container/bucket.
Rackspace Cloud Files: If public is set to true the container be CDN-enabled and all of its contents will be publicly readable.
Amazon: If public is set to true the bucket will have a policy making everything inside the bucket public.
Google: If public is set to true the bucket will set the default access control on objects to public but they can be later changed.

Return Value: true if successful.

createContainer($name, $public = false)
Parameter Description
$name Container name (keep in mind this must be unique among all other containers)
$public true for public, defaults to false

createFile

Creates a new file in the given container.
Rackspace Cloud Files ignores "access" — public/private is controlled through the container only.

Return Value: The URL of the file if successful.

createFile($contents, $container, $pointer, $public = false, $type = "")
Parameter Description
$contents What to write to the file.
$container Container name.
$pointer The full file path inside the container.
$public true to make publicly accessible, defaults to false (this setting is ignored in Rackspace Cloud Files and is ignored in Amazon S3 if the bucket's policy is set to public)
$type MIME type (defaults to using the file extension, falls back to text/plain)

createFolder

Creates a new folder in the given container.

Return Value: true if successful.

createFolder($container, $pointer)
Parameter Description
$container Container name.
$pointer The full folder path inside the container.

deleteContainer

Deletes a container/bucket.
Containers must be empty to be deleted.

Return Value: true if successful.

deleteContainer($container)
Parameter Description
$container Container to delete.

deleteFile

Deletes a file from the given container.

Return Value: true if successful

deleteFile($container, $pointer)
Parameter Description
$container The container the file is stored in.
$pointer The full file path inside the container.

getAuthenticatedFileURL

Returns a URL that is valid for a limited amount of time to a private file.

Return Value: A URL.

getAuthenticatedFileURL($container, $pointer, $expires)
Parameter Description
$container The container the file is in.
$pointer The full file path inside the container.
$expires The number of seconds before this URL will expire.

getCloudFrontDistributions

Returns an array of distributions.

Return Value: An array or null if the API call failed.

getCloudFrontDistributions()

getContainer

Lists the contents of a container/bucket.

Return Value: An array of the contents of the container.

getContainer($container, $simple = false)
Parameter Description
$container The name of the container.
$simple Simple mode (returns only a flat array with name/path/size, defaults to false)

getFile

Returns a file from the given container.

Return Value: A binary stream of data or false if the file is not found or not allowed.

getFile($container, $pointer)
Parameter Description
$container The container the file is stored in.
$pointer The full file path inside the container.

getFolder

Returns the folder "contents" from a container.

Return Value: A keyed array of files and folders inside the folder or false if the folder was not found.

getFolder($container, $folder)
Parameter Description
$container Either a string of the name of the container the folder resides in OR the response from a previous getContainer call.
$folder The full folder path inside the container.

getRackspaceToken

Gets a new access token for the Rackspace Cloud Files API.

getRackspaceToken()

getS3BucketExists

Returns true if a bucket of the specified name already exists.

Return Value: true if bucket exists, else false

getS3BucketExists($bucket)
Parameter Description
$bucket

getS3BucketPage

Returns a page of contents of an Amazon S3 bucket.

Return Value: $this->NextPage is set to the next page marker token

getS3BucketPage($bucket, $marker = null)
Parameter Description
$bucket The name of the bucket.
$marker A page marker token (or null to start from the beginning)

getS3BucketRegion

Returns the proper region for the specified bucket.

Return Value: A region name or false if the bucket does not exist or is not accessible.

getS3BucketRegion($bucket)
Parameter Description
$bucket A bucket name

invalidateCache

Invalidates the CloudFront cache for a given pointer.

Return Value: true if successful

invalidateCache($pointer)
Parameter Description
$pointer The pointer to invalidate

listContainers

Lists containers/buckets that are available in this cloud account.

Return Value: An array of container names.

listContainers()

makeFilePublic

Makes a file readable to the public.
Rackspace Cloud Files does not support this method.

Return Value: The true successful, otherwise false

makeFilePublic($container, $pointer)
Parameter Description
$container The container/bucket the file is in
$pointer The pointer to the file.

resetCache

Clears the bigtree_caches table of container data and resets it with new data.

resetCache($data)
Parameter Description
$data An array of file data from a container

setupAmazon

Sets up the S3/CloudFront clients for Amazon calls.

setupAmazon()

uploadFile

Creates a new file in the given container.
Rackspace Cloud Files ignores "access" — public/private is controlled through the container only.

Return Value: The URL of the file if successful.

uploadFile($file, $container, $pointer = false, $public = false, $type)
Parameter Description
$file The file to upload.
$container Container name.
$pointer The full file path inside the container (if left empty the file's current name will be used and the root of the bucket)
$public true to make publicly accessible, defaults to false (this setting is ignored in Rackspace Cloud Files and is ignored in Amazon S3 if the bucket's policy is set to public)
$type MIME type (defaults to "text/plain")

callRackspace

cURL wrapper for Rackspace.

callRackspace($endpoint = "", $data = false, $curl_options = [])
Parameter Description
$endpoint Endpoint to hit.
$data Request body data.
$curl_options Additional cURL options.