blesta / amazon-s3-php-class
PHP 7.2.x 独立的 Amazon S3 (REST) 客户端,使用 CURL,无需 PEAR。
0.6.0
2022-04-21 16:51 UTC
Requires
- php: >=7.2.0|>=8.0
- ext-openssl: *
This package is auto-updated.
Last update: 2024-09-21 22:59:29 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)