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)
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)
Convert a hex string to a base64 string (stolen from the example)
void
hex2b64
(mixed $str)
Get a list of all your s3 buckets (directories)
void
lsBuckets
()
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])
Make an Amazon S3 container object (directory)
Takes ($s3bucket)
- [str] $s3bucket: the bucket/directory you wish to create
void
mkBucket
(mixed $s3bucket)
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])
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])
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)
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)
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)
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"])
Tell me why something failed!
Returns an array of the values returned, via the xml output, from the s3 service
void
why
()