<?php
namespace OSS;
use OSS\Core\MimeTypes;
use OSS\Core\OssException;
use OSS\Http\RequestCore;
use OSS\Http\RequestCore_Exception;
use OSS\Http\ResponseCore;
use OSS\Model\CorsConfig;
use OSS\Model\CnameConfig;
use OSS\Model\LoggingConfig;
use OSS\Model\LiveChannelConfig;
use OSS\Model\LiveChannelInfo;
use OSS\Model\LiveChannelListInfo;
use OSS\Model\StorageCapacityConfig;
use OSS\Result\AclResult;
use OSS\Result\BodyResult;
use OSS\Result\GetCorsResult;
use OSS\Result\GetLifecycleResult;
use OSS\Result\GetLocationResult;
use OSS\Result\GetLoggingResult;
use OSS\Result\GetRefererResult;
use OSS\Result\GetStorageCapacityResult;
use OSS\Result\GetWebsiteResult;
use OSS\Result\GetCnameResult;
use OSS\Result\HeaderResult;
use OSS\Result\InitiateMultipartUploadResult;
use OSS\Result\ListBucketsResult;
use OSS\Result\ListMultipartUploadResult;
use OSS\Model\ListMultipartUploadInfo;
use OSS\Result\ListObjectsResult;
use OSS\Result\ListPartsResult;
use OSS\Result\PutSetDeleteResult;
use OSS\Result\DeleteObjectsResult;
use OSS\Result\CopyObjectResult;
use OSS\Result\CallbackResult;
use OSS\Result\ExistResult;
use OSS\Result\PutLiveChannelResult;
use OSS\Result\GetLiveChannelHistoryResult;
use OSS\Result\GetLiveChannelInfoResult;
use OSS\Result\GetLiveChannelStatusResult;
use OSS\Result\ListLiveChannelResult;
use OSS\Result\AppendResult;
use OSS\Model\ObjectListInfo;
use OSS\Result\SymlinkResult;
use OSS\Result\UploadPartResult;
use OSS\Model\BucketListInfo;
use OSS\Model\LifecycleConfig;
use OSS\Model\RefererConfig;
use OSS\Model\WebsiteConfig;
use OSS\Core\OssUtil;
use OSS\Model\ListPartsInfo;
use OSS\Result\GetBucketInfoResult;
use OSS\Model\BucketStat;
use OSS\Result\GetBucketStatResult;
use OSS\Model\ServerSideEncryptionConfig;
use OSS\Result\GetBucketEncryptionResult;
use OSS\Model\RequestPaymentConfig;
use OSS\Result\GetBucketRequestPaymentResult;
use OSS\Model\Tag;
use OSS\Model\TaggingConfig;
use OSS\Result\GetBucketTagsResult;
use OSS\Model\VersioningConfig;
use OSS\Result\GetBucketVersioningResult;
use OSS\Model\InitiateWormConfig;
use OSS\Result\InitiateBucketWormResult;
use OSS\Model\ExtendWormConfig;
use OSS\Result\GetBucketWormResult;
use OSS\Model\RestoreConfig;
use OSS\Model\ObjectVersionListInfo;
use OSS\Result\ListObjectVersionsResult;
use OSS\Model\DeleteObjectInfo;
use OSS\Model\DeletedObjectInfo;
use OSS\Result\DeleteObjectVersionsResult;
/**
* Class OssClient
*
* Object Storage Service(OSS)'s client class, which wraps all OSS APIs user could call to talk to OSS.
* Users could do operations on bucket, object, including MultipartUpload or setting ACL via an OSSClient instance.
* For more details, please check out the OSS API document:https://www.alibabacloud.com/help/doc-detail/31947.htm
*/
class OssClient
{
/**
* Constructor
*
* There're a few different ways to create an OssClient object:
* 1. Most common one from access Id, access Key and the endpoint: $ossClient = new OssClient($id, $key, $endpoint)
* 2. If the endpoint is the CName (such as www.testoss.com, make sure it's CName binded in the OSS console),
* uses $ossClient = new OssClient($id, $key, $endpoint, true)
* 3. If using Alicloud's security token service (STS), then the AccessKeyId, AccessKeySecret and STS token are all got from STS.
* Use this: $ossClient = new OssClient($id, $key, $endpoint, false, $token)
* 4. If the endpoint is in IP format, you could use this: $ossClient = new OssClient($id, $key, “1.2.3.4:8900”)
*
* @param string $accessKeyId The AccessKeyId from OSS or STS
* @param string $accessKeySecret The AccessKeySecret from OSS or STS
* @param string $endpoint The domain name of the datacenter,For example: oss-cn-hangzhou.aliyuncs.com
* @param boolean $isCName If this is the CName and binded in the bucket.
* @param string $securityToken from STS.
* @param string $requestProxy
* @throws OssException
*/
public function __construct($accessKeyId, $accessKeySecret, $endpoint, $isCName = false, $securityToken = NULL, $requestProxy = NULL)
{
$accessKeyId = trim($accessKeyId);
$accessKeySecret = trim($accessKeySecret);
$endpoint = trim(trim($endpoint), "/");
if (empty($accessKeyId)) {
throw new OssException("access key id is empty");
}
if (empty($accessKeySecret)) {
throw new OssException("access key secret is empty");
}
if (empty($endpoint)) {
throw new OssException("endpoint is empty");
}
$this->hostname = $this->checkEndpoint($endpoint, $isCName);
$this->accessKeyId = $accessKeyId;
$this->accessKeySecret = $accessKeySecret;
$this->securityToken = $securityToken;
$this->requestProxy = $requestProxy;
self::checkEnv();
}
/**
* Lists the Bucket [GetService]. Not applicable if the endpoint is CName (because CName must be binded to a specific bucket).
*
* @param array $options
* @throws OssException
* @return BucketListInfo
*/
public function listBuckets($options = NULL)
{
if ($this->hostType === self::OSS_HOST_TYPE_CNAME) {
throw new OssException("operation is not permitted with CName host");
}
$this->precheckOptions($options);
$options[self::OSS_BUCKET] = '';
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_OBJECT] = '/';
$response = $this->auth($options);
$result = new ListBucketsResult($response);
return $result->getData();
}
/**
* Creates bucket,The ACL of the bucket created by default is OssClient::OSS_ACL_TYPE_PRIVATE
*
* @param string $bucket
* @param string $acl
* @param array $options
* @param string $storageType
* @return null
*/
public function createBucket($bucket, $acl = self::OSS_ACL_TYPE_PRIVATE, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_OBJECT] = '/';
$options[self::OSS_HEADERS] = array(self::OSS_ACL => $acl);
if (isset($options[self::OSS_STORAGE])) {
$this->precheckStorage($options[self::OSS_STORAGE]);
$options[self::OSS_CONTENT] = OssUtil::createBucketXmlBody($options[self::OSS_STORAGE]);
unset($options[self::OSS_STORAGE]);
}
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
}
/**
* Deletes bucket
* The deletion will not succeed if the bucket is not empty (either has objects or parts)
* To delete a bucket, all its objects and parts must be deleted first.
*
* @param string $bucket
* @param array $options
* @return null
*/
public function deleteBucket($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_DELETE;
$options[self::OSS_OBJECT] = '/';
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
}
/**
* Checks if a bucket exists
*
* @param string $bucket
* @return bool
* @throws OssException
*/
public function doesBucketExist($bucket)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_OBJECT] = '/';
$options[self::OSS_SUB_RESOURCE] = 'acl';
$response = $this->auth($options);
$result = new ExistResult($response);
return $result->getData();
}
/**
* Get the data center loc
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
2023年最新7国语言二开做任务源码 重构UI+详细搭建教程 (2306个子文件)
cityjson 84B
app.3227f3b635185d55fe635aae11c7880e.css 725KB
app.7b22fa66c2af28f12bf32977d4b82694.css 725KB
mobiscroll.custom-3.0.0-beta6.min.css 237KB
bootstrap.css 195KB
bootstrap.min.css 158KB
bootstrap.min.css 156KB
light7.css 129KB
style.css 123KB
layui.css 71KB
bootstrap-grid.css 66KB
bootstrap-grid.min.css 49KB
editor_ie8.css 49KB
editor_iequirks.css 48KB
editor_ie.css 48KB
font.css 48KB
editor_gecko.css 47KB
editor.css 47KB
hui.css 45KB
userstyle.css 36KB
fonts.css 30KB
index_style.css 30KB
console.css 25KB
intlTelInput.css 25KB
user.css 25KB
light7-swiper.css 22KB
share.css 20KB
intlTelInput.min.css 19KB
swiper.min.css 19KB
base.css 17KB
base.css 17KB
public.css 16KB
dialog_ie8.css 15KB
dialog_iequirks.css 14KB
dialog_ie.css 14KB
layer.css 14KB
swiper-bundle.min.css 14KB
dialog.css 13KB
swiper.min.css 13KB
layui.mobile.css 10KB
funding.css 9KB
funding.css 9KB
console.custom.css 9KB
deposit.css 8KB
my.css 8KB
laydate.css 7KB
register-login.css 7KB
reg.css 7KB
style2.css 7KB
index.css 7KB
unlock.css 6KB
mobile.css 6KB
zTreeStyle.css 6KB
team-reports.css 6KB
grab.css 6KB
michat.css 5KB
account.css 5KB
layer.css 5KB
deposit-record.css 5KB
login.css 5KB
bootstrap-reboot.css 5KB
index.css 5KB
account-details.css 4KB
console.layout.css 4KB
record.css 4KB
bootstrap-reboot.min.css 4KB
withdrawal.css 4KB
theme.css 4KB
mobileSelect.css 3KB
accesssub.css 3KB
console.form.css 3KB
lixibao.css 3KB
iconfont.css 3KB
access.css 3KB
contents.css 3KB
icon-font.css 3KB
record.css 3KB
common.css 3KB
console.layui.css 2KB
login.css 2KB
recharge.css 2KB
rolldate.css 2KB
personal.css 2KB
style.css 2KB
templates.css 2KB
copyformatting.css 1KB
autocompleter.css 1KB
invitation.css 1KB
wsc.css 1KB
toolbar.css 1KB
wsc.css 1KB
order.css 1KB
notice.css 1KB
ui.css 1KB
supersized.css 1KB
tableselection.css 1KB
demo.css 1KB
code.css 1KB
announcement.css 970B
service.css 891B
共 2306 条
- 1
- 2
- 3
- 4
- 5
- 6
- 24
资源评论
如鹿觅水
- 粉丝: 180
- 资源: 376
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功