rastor/amazon-s3-php-class

一个独立的PHP 5.2.x版本的Amazon S3 (REST)客户端,使用CURL,不需要PEAR。

这个包的官方仓库似乎已不存在,因此该包已被冻结。

0.5.1 2014-10-01 14:18 UTC

This package is auto-updated.

Last update: 2022-05-29 00:41:38 UTC


README

使用方法

面向对象方法(例如;$s3->getObject(...))

$s3 = new S3($awsAccessKey, $awsSecretKey);

静态方法(例如;S3::getObject(...))

S3::setAuth($awsAccessKey, $awsSecretKey);

对象操作

上传对象

从文件中上传对象

S3::putObject(S3::inputFile($file, false), $bucketName, $uploadName, S3::ACL_PUBLIC_READ)

从字符串中上传对象并设置其Content-Type

S3::putObject($string, $bucketName, $uploadName, S3::ACL_PUBLIC_READ, array(), array('Content-Type' => 'text/plain'))

从资源中上传对象(需要资源大小 - 注意:资源将被fclose()自动关闭)

S3::putObject(S3::inputResource(fopen($file, 'rb'), filesize($file)), $bucketName, $uploadName, S3::ACL_PUBLIC_READ)

检索对象

获取对象

S3::getObject($bucketName, $uploadName)

将对象保存到文件

S3::getObject($bucketName, $uploadName, $saveName)

将对象保存到任何类型的资源

S3::getObject($bucketName, $uploadName, fopen('savefile.txt', 'wb'))

复制和删除对象

复制对象

S3::copyObject($srcBucket, $srcName, $bucketName, $saveName, $metaHeaders = array(), $requestHeaders = array())

删除对象

S3::deleteObject($bucketName, $uploadName)

存储桶操作

获取存储桶列表

S3::listBuckets()  // Simple bucket list
S3::listBuckets(true)  // Detailed bucket list

创建存储桶

S3::putBucket($bucketName)

获取存储桶内容

S3::getBucket($bucketName)

删除空存储桶

S3::deleteBucket($bucketName)