Class Storage3

Description

This class is the abstraction layer through which you provide easy access to the Amazon S3 API

Takes ($key, $secret, $url)

  • [str] $key: Your Amazon Web Services Access Key ID
  • [str] $secret: Your Amazon Web Services Secret Access Key
  • [str] $url: OPTIONAL (default: http://s3.amazonaws.com/)
Example Usage:

   $s3=new storage3("aslkdfjhalskdfjhals", "sdalkjfhaslkjdfhaslkdhjfaslkjdhflas");

   $s3->lsBuckets();
   $s3->lsFiles("apokalyptik2");

   $s3->mkBucket("apokalyptik2");
   $s3->mkFile("blah do blah", "apokalyptik2", "test", "binary/octet-stream", time()+300);

   $s3->getFile('apokalyptik2', 'test');

   $s3->rmFile('apokalyptik2', "test");
   $s3->rmBucket('apokalyptik2');
 

Located in /Storage3.php (line 42)


	
			
Method Summary
void fileExists (mixed $s3bucket, mixed $s3file)
void getFile (mixed $s3bucket, mixed $s3file)
void hex2b64 (mixed $str)
void lsBuckets ()
void lsFiles (mixed $s3bucket, [mixed $pageKey = FALSE], [mixed $maxKeys = 500])
void mkBucket (mixed $s3bucket)
void mkFile (mixed $string, mixed $s3bucket, mixed $s3file, [mixed $contentType = "binary/octet-stream"], [mixed $contentExpires = FALSE], [mixed $contentDisposition = FALSE], [mixed $cacheControl = FALSE], [mixed $defaultAcl = FALSE])
void putFile (mixed $fileName, mixed $s3bucket, mixed $s3file, [mixed $contentType = "binary/octet-stream"], [mixed $contentExpires = FALSE], [mixed $contentDisposition = FALSE], [mixed $cacheControl = FALSE])
void rmBucket (mixed $s3bucket, mixed $recursive)
void rmFile (mixed $s3bucket, mixed $s3file)
void saveFile (mixed $s3bucket, mixed $s3file, mixed $fileName)
void setACL (mixed $s3bucket, mixed $s3file, [mixed $shorthand = "public-read"])
void why ()
Methods
fileExists (line 381)

Find out if an object already exists in s3

  • Takes ($s3bucket, $s3file)
  • Returns bool (TRUE: exists, FALSE: doesn't exist)
  • [str] $s3bucket, REQUIRED, the bucket in which the target object is located
  • [str] $s3file, REQUIRED, the object on which you wish to check

void fileExists (mixed $s3bucket, mixed $s3file)
getFile (line 229)

Get data from an S3 file object and return it as a string

Takes ($s3bucket, $s3file)

  • [str] $s3bucket: The bucket/directory which holds the file
  • [str] $s3file: The file, from, the bucket/directory which to retrieve

void getFile (mixed $s3bucket, mixed $s3file)
hex2b64 (line 509)

Convert a hex string to a base64 string (stolen from the example)

void hex2b64 (mixed $str)
lsBuckets (line 72)

Get a list of all your s3 buckets (directories)

void lsBuckets ()
lsFiles (line 100)

Retrieve a list of all files from a bucket (directory)

Takes ($s3bucket)

  • [str] $s3bucket: the bucket/directory which you would like a listing of

void lsFiles (mixed $s3bucket, [mixed $pageKey = FALSE], [mixed $maxKeys = 500])
mkBucket (line 256)

Make an Amazon S3 container object (directory)

Takes ($s3bucket)

  • [str] $s3bucket: the bucket/directory you wish to create

void mkBucket (mixed $s3bucket)
mkFile (line 312)

Put data (in the form of a passed string) into an S3 file object. If you specify an object to which you have write privileges and already exists... this will overwrite that object

Takes ($string, $s3bucket, $s3file, $contentType, $contentExpires, $contentDisposition, $cacheControl)

  • [str] $string: The file contents you wish to write to the object file
  • [str] $s3bucket: the bucket/directory you wish to store this file in
  • [str] $s3file: the name of the file object in which you would like to store data in side the bucket/directory
  • [str] $contentType: OPTIONAL: defaults: binary/octet-stream; see http://s3.amazonaws.com/doc/s3-developer-guide/RESTObjectPUT.html
  • [str] $contentExpires: OPTIONAL: defaults: OFF, the unix timestamp at which the file expires, see http://s3.amazonaws.com/doc/s3-developer-guide/RESTObjectPUT.html
  • [str] $contentDisposition: OPTIONAL: defaults: OFF, see http://s3.amazonaws.com/doc/s3-developer-guide/RESTObjectPUT.html
  • [str] $cacheControl: OPTIONAL: defaults: OFF, see http://s3.amazonaws.com/doc/s3-developer-guide/RESTObjectPUT.html

void mkFile (mixed $string, mixed $s3bucket, mixed $s3file, [mixed $contentType = "binary/octet-stream"], [mixed $contentExpires = FALSE], [mixed $contentDisposition = FALSE], [mixed $cacheControl = FALSE], [mixed $defaultAcl = FALSE])
putFile (line 294)

Read a file from the filesystem and put it into S3

Takes ($string, $s3bucket, $s3file, $contentType, $contentExpires, $contentDisposition, $cacheControl)

  • [str] $fileName: The file contents you wish to write to the object file
  • [str] $s3bucket: the bucket/directory you wish to store this file in
  • [str] $s3file: the name of the file object in which you would like to store data in side the bucket/directory
  • [str] $contentType: OPTIONAL: defaults: binary/octet-stream; see http://s3.amazonaws.com/doc/s3-developer-guide/RESTObjectPUT.html
  • [str] $contentExpires: OPTIONAL: defaults: OFF, the unix timestamp at which the file expires, see http://s3.amazonaws.com/doc/s3-developer-guide/RESTObjectPUT.html
  • [str] $contentDisposition: OPTIONAL: defaults: OFF, see http://s3.amazonaws.com/doc/s3-developer-guide/RESTObjectPUT.html
  • [str] $cacheControl: OPTIONAL: defaults: OFF, see http://s3.amazonaws.com/doc/s3-developer-guide/RESTObjectPUT.html

void putFile (mixed $fileName, mixed $s3bucket, mixed $s3file, [mixed $contentType = "binary/octet-stream"], [mixed $contentExpires = FALSE], [mixed $contentDisposition = FALSE], [mixed $cacheControl = FALSE])
rmBucket (line 171)

Delete an empty s3 bucket/directory. (The operation will fail if you attempt this on a bucket which is not empty)

Takes ($s3bucket, $recursive)

  • [str] $s3bucket: the bucket/directory which you would like to delete from s3.
  • [int] $recursive: OPTIONAL: DEFAULTS: 0, if set to 1 it will delete all files inside the bucket, and then delete the bucket. This is because attempting to delete a bucket which is not empty gives an error 409 "BucketNotEmpty" ("The bucket you tried to delete is not empty")

void rmBucket (mixed $s3bucket, mixed $recursive)
rmFile (line 141)

Delete a file object from your s3 account S3

Takes ($s3bucket, $s3file)

  • [str] $s3bucket: the bucket/directory from which you would like the file
  • [str] $s3file: the file which you would like from the bucket/directory

void rmFile (mixed $s3bucket, mixed $s3file)
saveFile (line 212)

Save data from s3 into a local file

Takes ($s3bucket, $s3file, $fileName)

  • [str] $s3bucket: The bucket/directory which holds the file
  • [str] $s3file: The file, from, the bucket/directory which to retrieve
  • [str] $fileName: The local filename in which to save your data

void saveFile (mixed $s3bucket, mixed $s3file, mixed $fileName)
setACL (line 420)

Set the acl for a file stored in S3

  • Takes ($s3bucket, $s3file, $shorthand)
  • Returns bool TRUE|FALSE
  • [str] $s3bucket, REQUIRED, the bucket in which the target object is located
  • [str] $s3file, REQUIRED, the object on which you wish to set the ACL
  • [str] $shorthand, OPTIONAL, DEFAULT: "public-read"
Contributed by "Nick" (http://www.katanapg.com/) April 5th, 2006 at 9:52 pm e

void setACL (mixed $s3bucket, mixed $s3file, [mixed $shorthand = "public-read"])
why (line 542)

Tell me why something failed!

Returns an array of the values returned, via the xml output, from the s3 service

void why ()

Documentation generated on Tue, 02 May 2006 13:33:11 -0700 by phpDocumentor 1.2.3