https://github.com/tpyo/amazon-s3-php-class
A standalone Amazon S3 (REST) client for PHP 5/CURL
https://github.com/tpyo/amazon-s3-php-class
Last synced: 6 months ago
JSON representation
A standalone Amazon S3 (REST) client for PHP 5/CURL
- Host: GitHub
- URL: https://github.com/tpyo/amazon-s3-php-class
- Owner: tpyo
- Created: 2011-04-12T04:50:02.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2025-02-19T22:07:19.000Z (over 1 year ago)
- Last Synced: 2025-07-18T14:50:17.504Z (11 months ago)
- Language: PHP
- Homepage:
- Size: 145 KB
- Stars: 1,036
- Watchers: 80
- Forks: 499
- Open Issues: 73
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Amazon S3 PHP Class
## Usage
OO method (e,g; $s3->getObject(...)):
```php
$s3 = new S3($awsAccessKey, $awsSecretKey);
```
Statically (e,g; S3::getObject(...)):
```php
S3::setAuth($awsAccessKey, $awsSecretKey);
```
### Object Operations
#### Uploading objects
Put an object from a file:
```php
S3::putObject(S3::inputFile($file, false), $bucketName, $uploadName, S3::ACL_PUBLIC_READ)
```
Put an object from a string and set its Content-Type:
```php
S3::putObject($string, $bucketName, $uploadName, S3::ACL_PUBLIC_READ, array(), array('Content-Type' => 'text/plain'))
```
Put an object from a resource (buffer/file size is required - note: the resource will be fclose()'d automatically):
```php
S3::putObject(S3::inputResource(fopen($file, 'rb'), filesize($file)), $bucketName, $uploadName, S3::ACL_PUBLIC_READ)
```
#### Retrieving objects
Get an object:
```php
S3::getObject($bucketName, $uploadName)
```
Save an object to file:
```php
S3::getObject($bucketName, $uploadName, $saveName)
```
Save an object to a resource of any type:
```php
S3::getObject($bucketName, $uploadName, fopen('savefile.txt', 'wb'))
```
#### Copying and deleting objects
Copy an object:
```php
S3::copyObject($srcBucket, $srcName, $bucketName, $saveName, $metaHeaders = array(), $requestHeaders = array())
```
Delete an object:
```php
S3::deleteObject($bucketName, $uploadName)
```
### Bucket Operations
Get a list of buckets:
```php
S3::listBuckets() // Simple bucket list
S3::listBuckets(true) // Detailed bucket list
```
Create a bucket:
```php
S3::putBucket($bucketName)
```
Get the contents of a bucket:
```php
S3::getBucket($bucketName)
```
Delete an empty bucket:
```php
S3::deleteBucket($bucketName)
```