cineman / amazon-s3-php-class
PHP 5.2.x 独立客户端,用于 Amazon S3 (REST),使用 CURL,无需 PEAR。
v0.6.3
2022-03-24 12:15 UTC
Requires
- php: >=5.2.0
This package is not auto-updated.
Last update: 2024-09-18 08:41:22 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)