code
stringlengths 17
247k
| docstring
stringlengths 30
30.3k
| func_name
stringlengths 1
89
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
153
| url
stringlengths 51
209
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function handleProviderCallback($type)
{
if ($this->checkOauthType($type)) {
return abort(404);
}
$oauthUser = Socialite::driver($type)->stateless()->user();
// $user = $driver->user();
switch (strtolower($type)) {
case 'weixin':
$unionid = $oauthUser->offsetExists('unionid') ? $oauthUser->offsetGet('unionid') : null;
if ($unionid) {
$user = User::where('weixin_unionid', $unionid)->first();
} else {
$user = User::where('weixin_openid', $oauthUser->getId())->first();
}
$userAttributes = [
'weixin_unionid' => $unionid,
'weixin_openid' => $oauthUser->getId(),
];
break;
case 'weibo':
$user = User::where('weibo_id', $oauthUser->getId())->first();
$userAttributes = [
'weibo_id' => $oauthUser->getId(),
];
break;
case 'qq':
$user = User::where('qq_id', $oauthUser->getId())->first();
$userAttributes = [
'qq_id' => $oauthUser->getId(),
];
break;
case 'github':
$user = User::where('github_id', $oauthUser->getId())->first();
$userAttributes = [
'github_id' => $oauthUser->getId(),
];
break;
}
// 没有用户且未登录,默认创建一个用户
if (!$user && !Auth::check()) {
$user = User::create(array_merge([
'name' => $oauthUser->getNickname(),
// 'name' => 'lara_'.create_object_id(),
'avatar' => $oauthUser->getAvatar(),
],$userAttributes));
}else if(!$user && Auth::check()){
// 没有用户但是已登录,默认绑定
$user = Auth::user();
$user->update($userAttributes);
// $user->fill($userAttributes);
// $user->save();
return redirect()->route('user.settings','#bind')->with('success', '绑定成功.');
}else if($user && Auth::check() && ($user->id != Auth::user()->id) ){
return redirect()->route('user.settings','#bind')->with('danger', '已绑定过其它用户,不能重复绑定.');
}else if( $user && Auth::check() && ($user->id == Auth::user()->id) ){
return redirect()->route('user.settings','#bind')->with('danger', '已绑定,无需重复绑定.');
}
# 登录用户
Auth::login($user);
// return redirect()->route('user.settings','#info')->with('success', '成功登录.');
return redirect()->route('user.settings','#info');
// dd($oauthUser);
// $user->token;
} | Obtain the user information from GitHub.
@return Response | handleProviderCallback | php | wanglelecc/laracms | laracms/src/Http/Controllers/Auth/LoginController.php | https://github.com/wanglelecc/laracms/blob/master/laracms/src/Http/Controllers/Auth/LoginController.php | MIT |
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
} | Create a new user instance after a valid registration.
@param array $data
@return \Wanglelecc\Laracms\Models\User | create | php | wanglelecc/laracms | laracms/src/Http/Controllers/Auth/RegisterController.php | https://github.com/wanglelecc/laracms/blob/master/laracms/src/Http/Controllers/Auth/RegisterController.php | MIT |
public function report(Exception $exception)
{
parent::report($exception);
} | Report or log an exception.
This is a great spot to send exceptions to Sentry, Bugsnag, etc.
@param Exception $exception
@return mixed|void
@throws Exception | report | php | wanglelecc/laracms | laracms/src/Exceptions/Handler.php | https://github.com/wanglelecc/laracms/blob/master/laracms/src/Exceptions/Handler.php | MIT |
public function render($request, Exception $exception)
{
if ($exception instanceof AuthorizationException) {
return redirect()->guest(route('administrator.permission-denied'));
}
return parent::render($request, $exception);
} | Render an exception into an HTTP response.
@param \Illuminate\Http\Request $request
@param Exception $exception
@return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response | render | php | wanglelecc/laracms | laracms/src/Exceptions/Handler.php | https://github.com/wanglelecc/laracms/blob/master/laracms/src/Exceptions/Handler.php | MIT |
function env($key, $default = null)
{
$value = get_environment_variable($key);
if ($value === false) {
return value($default);
}
switch (strtolower($value)) {
case 'true':
case '(true)':
return true;
case 'false':
case '(false)':
return false;
case 'empty':
case '(empty)':
return '';
case 'null':
case '(null)':
return;
}
if (strlen($value) > 1 && Str::startsWith($value, '"') && Str::endsWith($value, '"')) {
return substr($value, 1, -1);
}
return $value;
} | Gets the value of an environment variable.
@param string $key
@param mixed $default
@return mixed | env | php | wanglelecc/laracms | laracms/src/Support/Helpers.php | https://github.com/wanglelecc/laracms/blob/master/laracms/src/Support/Helpers.php | MIT |
public function boot()
{
//
} | Bootstrap the application services.
@return void | boot | php | wanglelecc/laracms | laracms/src/Providers/EasySmsServiceProvider.php | https://github.com/wanglelecc/laracms/blob/master/laracms/src/Providers/EasySmsServiceProvider.php | MIT |
public function register()
{
$this->app->singleton(EasySms::class, function ($app) {
return new EasySms(config('easysms'));
});
$this->app->alias(EasySms::class, 'easysms');
} | Register the application services.
@return void | register | php | wanglelecc/laracms | laracms/src/Providers/EasySmsServiceProvider.php | https://github.com/wanglelecc/laracms/blob/master/laracms/src/Providers/EasySmsServiceProvider.php | MIT |
public function boot()
{
Storage::extend('aliyun', function ($app, $config) {
$accessKeyId = $config['access_key_id'];
$accessKeySecret = $config['access_key_secret'];
$endPoint = $config['oss_endpoint'];
$bucket = $config['oss_bucket'];
$prefix = null;
if (isset($config['oss_prefix'])) {
$prefix = $config['oss_prefix'];
}
$client = new OssClient($accessKeyId, $accessKeySecret, $endPoint);
$adapter = new AliyunOssAdapter($client, $bucket, $prefix);
$filesystem = new Filesystem($adapter);
$filesystem->addPlugin(new PutFile());
$filesystem->addPlugin(new SignedDownloadUrl());
return $filesystem;
});
} | Perform post-registration booting of services.
@return void | boot | php | wanglelecc/laracms | laracms/src/Providers/AliyunOssServiceProvider.php | https://github.com/wanglelecc/laracms/blob/master/laracms/src/Providers/AliyunOssServiceProvider.php | MIT |
public function via($notifiable)
{
return ['database'];
} | Get the notification's delivery channels.
@param mixed $notifiable
@return array | via | php | wanglelecc/laracms | laracms/src/Notifications/ArticleReplied.php | https://github.com/wanglelecc/laracms/blob/master/laracms/src/Notifications/ArticleReplied.php | MIT |
public function toArray($notifiable)
{
return [
//
];
} | Get the array representation of the notification.
@param mixed $notifiable
@return array | toArray | php | wanglelecc/laracms | laracms/src/Notifications/ArticleReplied.php | https://github.com/wanglelecc/laracms/blob/master/laracms/src/Notifications/ArticleReplied.php | MIT |
private function __initClient($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");
}
$provider = new StaticCredentialsProvider($accessKeyId, $accessKeySecret, $securityToken);
$config = array(
'endpoint' => $endpoint,
'cname' => $isCName,
'request_proxy' => $requestProxy,
'provider' => $provider
);
$this->__initNewClient($config);
} | 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 | __initClient | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
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;
$response = $this->auth($options);
$result = new ListBucketsResult($response);
return $result->getData();
} | Lists the Bucket [GetService]. Not applicable if the endpoint is CName (because CName must be binded to a specific bucket).
@param array $options
@return BucketListInfo|null
@throws OssException|RequestCore_Exception | listBuckets | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
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_HEADERS][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();
} | 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
@return null
@throws OssException|RequestCore_Exception | createBucket | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
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;
$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
@throws OssException|RequestCore_Exception | deleteBucket | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketLocation($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_SUB_RESOURCE] = 'location';
$response = $this->auth($options);
$result = new GetLocationResult($response);
return $result->getData();
} | Get the data center location information for the bucket
@param string $bucket
@param array $options
@return string|null
@throws OssException|RequestCore_Exception | getBucketLocation | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketMeta($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_HEAD;
$response = $this->auth($options);
$result = new HeaderResult($response);
return $result->getData();
} | Get the Meta information for the Bucket
@param string $bucket
@param array $options Refer to the SDK documentation
@return array|null
@throws OssException|RequestCore_Exception | getBucketMeta | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketLogging($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_SUB_RESOURCE] = 'logging';
$response = $this->auth($options);
$result = new GetLoggingResult($response);
return $result->getData();
} | Gets the bucket logging config
@param string $bucket bucket name
@param array $options by default is empty
@return LoggingConfig|null
@throws OssException|RequestCore_Exception | getBucketLogging | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function putBucketLogging($bucket, $targetBucket, $targetPrefix, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$this->precheckBucket($targetBucket, 'targetbucket is not allowed empty');
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_SUB_RESOURCE] = 'logging';
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$loggingConfig = new LoggingConfig($targetBucket, $targetPrefix);
$options[self::OSS_CONTENT] = $loggingConfig->serializeToXml();
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Sets the bycket logging config. Only owner can call this API.
@param string $bucket bucket name
@param string $targetBucket The logging file's bucket
@param string $targetPrefix The logging file's prefix
@param array $options By default is empty.
@return null
@throws OssException|RequestCore_Exception | putBucketLogging | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function deleteBucketLogging($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_SUB_RESOURCE] = 'logging';
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Deletes the bucket logging config
@param string $bucket bucket name
@param array $options
@return null
@throws OssException|RequestCore_Exception | deleteBucketLogging | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function putBucketWebsite($bucket, $websiteConfig, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_SUB_RESOURCE] = 'website';
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$options[self::OSS_CONTENT] = $websiteConfig->serializeToXml();
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Sets the website config in bucket---that is could make the bucket as a static website once the CName is binded.
@param string $bucket bucket name
@param WebsiteConfig $websiteConfig
@param array $options
@return null
@throws OssException|RequestCore_Exception | putBucketWebsite | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketWebsite($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_SUB_RESOURCE] = 'website';
$response = $this->auth($options);
$result = new GetWebsiteResult($response);
return $result->getData();
} | Gets the website config in the bucket
@param string $bucket bucket name
@param array $options
@return WebsiteConfig|null
@throws OssException|RequestCore_Exception | getBucketWebsite | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function deleteBucketWebsite($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_SUB_RESOURCE] = 'website';
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Deletes the website config in the bucket
@param string $bucket bucket name
@param array $options
@return null
@throws OssException|RequestCore_Exception | deleteBucketWebsite | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function putBucketCors($bucket, $corsConfig, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_SUB_RESOURCE] = 'cors';
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$options[self::OSS_CONTENT] = $corsConfig->serializeToXml();
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Sets the cross-origin-resource-sharing (CORS) rule. It would overwrite the originl one.
@param string $bucket bucket name
@param CorsConfig $corsConfig CORS config. Check out the details from OSS API document
@param array $options array
@return null
@throws OssException|RequestCore_Exception | putBucketCors | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function deleteBucketCors($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_SUB_RESOURCE] = 'cors';
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Deletes the bucket's CORS config and disable the CORS on the bucket.
@param string $bucket bucket name
@param array $options
@return null
@throws OssException|RequestCore_Exception | deleteBucketCors | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketCname($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_CNAME] = '';
$response = $this->auth($options);
$result = new GetCnameResult($response);
return $result->getData();
} | Gets the binded CName list of the bucket
@param string $bucket bucket name
@param array $options
@return CnameConfig|null
@throws OssException|RequestCore_Exception | getBucketCname | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function deleteBucketCname($bucket, $cname, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_POST;
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$cnameConfig = new CnameConfig();
$cnameConfig->addCname($cname);
$options[self::OSS_CONTENT] = $cnameConfig->serializeToXml();
$options[self::OSS_COMP] = 'delete';
$options[self::OSS_CNAME] = '';
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Remove a CName binding from the bucket
@param string $bucket bucket name
@param CnameConfig $cname
@param array $options
@return null
@throws OssException|RequestCore_Exception | deleteBucketCname | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function createBucketCnameToken($bucket, $cname, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_POST;
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$cnameConfig = new CnameConfig();
$cnameConfig->addCname($cname);
$options[self::OSS_CONTENT] = $cnameConfig->serializeToXml();
$options[self::OSS_COMP] = 'token';
$options[self::OSS_CNAME] = '';
$response = $this->auth($options);
$result = new CreateBucketCnameTokenResult($response);
return $result->getData();
} | create a cname token for a bucket
@param string $bucket bucket name
@param array $options
@return CnameTokenInfo|null
@throws OssException|RequestCore_Exception | createBucketCnameToken | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketCnameToken($bucket, $cname, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_COMP] = 'token';
$options[self::OSS_CNAME] = $cname;
$response = $this->auth($options);
$result = new GetBucketCnameTokenResult($response);
return $result->getData();
} | get a cname token for a bucket
@param string $bucket bucket name
@param array $options
@return CnameTokenInfo|null
@throws OssException|RequestCore_Exception | getBucketCnameToken | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function putBucketLiveChannel($bucket, $channelName, $channelConfig, $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] = $channelName;
$options[self::OSS_SUB_RESOURCE] = 'live';
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$options[self::OSS_CONTENT] = $channelConfig->serializeToXml();
$response = $this->auth($options);
$result = new PutLiveChannelResult($response);
$info = $result->getData();
$info->setName($channelName);
$info->setDescription($channelConfig->getDescription());
return $info;
} | Creates a Live Channel under a bucket
@param string $bucket bucket name
@param string channelName $channelName
@param LiveChannelConfig $channelConfig
@param array $options
@return LiveChannelInfo|null
@throws OssException|RequestCore_Exception | putBucketLiveChannel | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getLiveChannelInfo($bucket, $channelName, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_OBJECT] = $channelName;
$options[self::OSS_SUB_RESOURCE] = 'live';
$response = $this->auth($options);
$result = new GetLiveChannelInfoResult($response);
return $result->getData();
} | Gets the LiveChannel information by the channel name
@param string $bucket bucket name
@param string channelName $channelName
@param array $options
@return GetLiveChannelInfo|null
@throws OssException|RequestCore_Exception | getLiveChannelInfo | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getLiveChannelStatus($bucket, $channelName, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_OBJECT] = $channelName;
$options[self::OSS_SUB_RESOURCE] = 'live';
$options[self::OSS_COMP] = 'stat';
$response = $this->auth($options);
$result = new GetLiveChannelStatusResult($response);
return $result->getData();
} | Gets the status of LiveChannel
@param string $bucket bucket name
@param string channelName $channelName
@param array $options
@return GetLiveChannelStatus|null
@throws OssException|RequestCore_Exception | getLiveChannelStatus | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getLiveChannelHistory($bucket, $channelName, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_OBJECT] = $channelName;
$options[self::OSS_SUB_RESOURCE] = 'live';
$options[self::OSS_COMP] = 'history';
$response = $this->auth($options);
$result = new GetLiveChannelHistoryResult($response);
return $result->getData();
} | Gets the LiveChannel pushing streaming record
@param string $bucket bucket name
@param string channelName $channelName
@param array $options
@return GetLiveChannelHistory|null
@throws OssException|RequestCore_Exception | getLiveChannelHistory | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function listBucketLiveChannels($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_SUB_RESOURCE] = 'live';
$options[self::OSS_QUERY_STRING] = array(
'prefix' => isset($options['prefix']) ? $options['prefix'] : '',
'marker' => isset($options['marker']) ? $options['marker'] : '',
'max-keys' => isset($options['max-keys']) ? $options['max-keys'] : '',
);
$response = $this->auth($options);
$result = new ListLiveChannelResult($response);
$list = $result->getData();
$list->setBucketName($bucket);
return $list;
} | Gets the live channel list under a bucket.
@param string $bucket bucket name
@param array $options
@return LiveChannelListInfo|null
@throws OssException|RequestCore_Exception | listBucketLiveChannels | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function postVodPlaylist($bucket, $channelName, $playlistName, $setTime)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_POST;
$options[self::OSS_OBJECT] = $channelName . '/' . $playlistName;
$options[self::OSS_SUB_RESOURCE] = 'vod';
$options[self::OSS_LIVE_CHANNEL_END_TIME] = $setTime['EndTime'];
$options[self::OSS_LIVE_CHANNEL_START_TIME] = $setTime['StartTime'];
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Creates a play list file for the LiveChannel
@param string $bucket bucket name
@param string channelName $channelName
@param string $playlistName The playlist name, must end with ".m3u8".
@param array $setTime startTime and EndTime in unix time. No more than 1 day.
@return null
@throws OssException|RequestCore_Exception | postVodPlaylist | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function deleteBucketLiveChannel($bucket, $channelName, $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] = $channelName;
$options[self::OSS_SUB_RESOURCE] = 'live';
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Deletes the Bucket LiveChannel
@param string $bucket bucket name
@param string channelName $channelName
@param array $options
@return null
@throws OssException|RequestCore_Exception | deleteBucketLiveChannel | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function optionsObject($bucket, $object, $origin, $request_method, $request_headers, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_OPTIONS;
$options[self::OSS_OBJECT] = $object;
$options[self::OSS_HEADERS][self::OSS_OPTIONS_ORIGIN] = $origin;
$options[self::OSS_HEADERS][self::OSS_OPTIONS_REQUEST_HEADERS] = $request_headers;
$options[self::OSS_HEADERS][self::OSS_OPTIONS_REQUEST_METHOD] = $request_method;
$response = $this->auth($options);
$result = new HeaderResult($response);
return $result->getData();
} | Precheck the CORS request. Before sending a CORS request, a preflight request (OPTIONS) is sent with the specific origin.
HTTP METHOD and headers information are sent to OSS as well for evaluating if the CORS request is allowed.
Note: OSS could enable the CORS on the bucket by calling putBucketCors. Once CORS is enabled, the OSS could evaluate accordingto the preflight request.
@param string $bucket bucket name
@param string $object object name
@param string $origin the origin of the request
@param string $request_method The actual HTTP method which will be used in CORS request
@param string $request_headers The actual HTTP headers which will be used in CORS request
@param array $options
@return array|null
@throws OssException|RequestCore_Exception | optionsObject | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function putBucketLifecycle($bucket, $lifecycleConfig, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_SUB_RESOURCE] = 'lifecycle';
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$options[self::OSS_CONTENT] = $lifecycleConfig->serializeToXml();
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Sets the bucket's lifecycle config
@param string $bucket bucket name
@param LifecycleConfig $lifecycleConfig LifecycleConfig instance
@param array $options
@return array|null
@throws OssException|RequestCore_Exception | putBucketLifecycle | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketLifecycle($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_SUB_RESOURCE] = 'lifecycle';
$response = $this->auth($options);
$result = new GetLifecycleResult($response);
return $result->getData();
} | Gets bucket's lifecycle config
@param string $bucket bucket name
@param array $options
@return LifecycleConfig|null
@throws OssException|RequestCore_Exception | getBucketLifecycle | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function deleteBucketLifecycle($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_SUB_RESOURCE] = 'lifecycle';
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Deletes the bucket's lifecycle config
@param string $bucket bucket name
@param array $options
@return array|null
@throws OssException|RequestCore_Exception | deleteBucketLifecycle | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function putBucketReferer($bucket, $refererConfig, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_SUB_RESOURCE] = 'referer';
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$options[self::OSS_CONTENT] = $refererConfig->serializeToXml();
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Sets a bucket's referer, which has a whitelist of referrer and specifies if empty referer is allowed.
Checks out API document for more details about "Bucket Referer"
@param string $bucket bucket name
@param RefererConfig $refererConfig
@param array $options
@return array|null
@throws OssException|RequestCore_Exception | putBucketReferer | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketReferer($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_SUB_RESOURCE] = 'referer';
$response = $this->auth($options);
$result = new GetRefererResult($response);
return $result->getData();
} | Gets the bucket's Referer
Checks out API document for more details about "Bucket Referer"
@param string $bucket bucket name
@param array $options
@return RefererConfig|null
@throws OssException|RequestCore_Exception | getBucketReferer | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function putBucketStorageCapacity($bucket, $storageCapacity, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_SUB_RESOURCE] = 'qos';
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$storageCapacityConfig = new StorageCapacityConfig($storageCapacity);
$options[self::OSS_CONTENT] = $storageCapacityConfig->serializeToXml();
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Set the size of the bucket,the unit is GB
When the capacity of the bucket is bigger than the set, it's forbidden to continue writing
@param string $bucket bucket name
@param int $storageCapacity
@param array $options
@return array|null
@throws OssException|RequestCore_Exception | putBucketStorageCapacity | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketStorageCapacity($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_SUB_RESOURCE] = 'qos';
$response = $this->auth($options);
$result = new GetStorageCapacityResult($response);
return $result->getData();
} | Get the capacity of the bucket, the unit is GB
@param string $bucket bucket name
@param array $options
@return int|null
@throws OssException|RequestCore_Exception | getBucketStorageCapacity | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketInfo($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_SUB_RESOURCE] = 'bucketInfo';
$response = $this->auth($options);
$result = new GetBucketInfoResult($response);
return $result->getData();
} | Get the information of the bucket
@param string $bucket bucket name
@param array $options
@return BucketInfo|null
@throws OssException|RequestCore_Exception | getBucketInfo | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function deleteBucketEncryption($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_SUB_RESOURCE] = 'encryption';
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Deletes the bucket's encryption
@param string $bucket bucket name
@param array $options
@return array|null
@throws OssException|RequestCore_Exception | deleteBucketEncryption | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function putBucketRequestPayment($bucket, $payer, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_SUB_RESOURCE] = 'requestPayment';
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$config = new RequestPaymentConfig($payer);
$options[self::OSS_CONTENT] = $config->serializeToXml();
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Set the request playment of the bucket, Can be BucketOwner and Requester
@param string $bucket bucket name
@param string $payer
@param array $options
@return array|null
@throws OssException|RequestCore_Exception | putBucketRequestPayment | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketRequestPayment($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_SUB_RESOURCE] = 'requestPayment';
$response = $this->auth($options);
$result = new GetBucketRequestPaymentResult($response);
return $result->getData();
} | Get the request playment of the bucket
@param string $bucket bucket name
@param array $options
@return string|null
@throws OssException|RequestCore_Exception | getBucketRequestPayment | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function putBucketVersioning($bucket, $status, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_SUB_RESOURCE] = 'versioning';
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$config = new VersioningConfig($status);
$options[self::OSS_CONTENT] = $config->serializeToXml();
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Set the versioning of the bucket, Can be BucketOwner and Requester
@param string $bucket bucket name
@param string $status
@param array $options
@return array|null
@throws OssException|RequestCore_Exception | putBucketVersioning | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketVersioning($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_SUB_RESOURCE] = 'versioning';
$response = $this->auth($options);
$result = new GetBucketVersioningResult($response);
return $result->getData();
} | Get the versioning of the bucket
@param string $bucket bucket name
@param array $options
@return string|null
@throws OssException|RequestCore_Exception | getBucketVersioning | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function putBucketTransferAcceleration($bucket, $enabled, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_SUB_RESOURCE] = 'transferAcceleration';
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$config = new TransferAccelerationConfig();
$config->setEnabled($enabled);
$options[self::OSS_CONTENT] = $config->serializeToXml();
$response = $this->auth($options);
$result = new HeaderResult($response);
return $result->getData();
} | Put Bucket TransferAcceleration
@param $bucket
@param $enabled boolean
@param array $options
@return array|null
@throws OssException|RequestCore_Exception | putBucketTransferAcceleration | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getBucketTransferAcceleration($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_SUB_RESOURCE] = 'transferAcceleration';
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$response = $this->auth($options);
$result = new GetBucketTransferAccelerationResult($response);
return $result->getData();
} | Put Bucket TransferAcceleration
@param $bucket
@param array $options
@return boolean|null
@throws OssException|RequestCore_Exception | getBucketTransferAcceleration | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function listObjects($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array();
$options[self::OSS_QUERY_STRING] = array_merge(
$query,
array(self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL,
self::OSS_DELIMITER => isset($options[self::OSS_DELIMITER]) ? $options[self::OSS_DELIMITER] : '/',
self::OSS_PREFIX => isset($options[self::OSS_PREFIX]) ? $options[self::OSS_PREFIX] : '',
self::OSS_MAX_KEYS => isset($options[self::OSS_MAX_KEYS]) ? $options[self::OSS_MAX_KEYS] : self::OSS_MAX_KEYS_VALUE,
self::OSS_MARKER => isset($options[self::OSS_MARKER]) ? $options[self::OSS_MARKER] : '')
);
$response = $this->auth($options);
$result = new ListObjectsResult($response);
return $result->getData();
} | Lists the bucket's object list (in ObjectListInfo)
@param string $bucket
@param array $options are defined below:
$options = array(
'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000.
'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix.
'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjects will differeniate the object and folder. And it will return subfolder's objects.
'marker' => The key of returned object must be greater than the 'marker'.
)
Prefix and marker are for filtering and paging. Their length must be less than 256 bytes
@return ObjectListInfo|null
@throws OssException|RequestCore_Exception | listObjects | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function listObjectsV2($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array();
$temp = array(
self::OSS_LIST_TYPE => 2,
self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL,
self::OSS_DELIMITER => isset($options[self::OSS_DELIMITER]) ? $options[self::OSS_DELIMITER] : '/',
self::OSS_PREFIX => isset($options[self::OSS_PREFIX]) ? $options[self::OSS_PREFIX] : '',
self::OSS_MAX_KEYS => isset($options[self::OSS_MAX_KEYS]) ? $options[self::OSS_MAX_KEYS] : self::OSS_MAX_KEYS_VALUE,
self::OSS_START_AFTER => isset($options[self::OSS_START_AFTER]) ? $options[self::OSS_START_AFTER] : '',
);
if (isset($options[self::OSS_CONTINUATION_TOKEN])) {
$temp[self::OSS_CONTINUATION_TOKEN] = $options[self::OSS_CONTINUATION_TOKEN];
}
$options[self::OSS_QUERY_STRING] = array_merge(
$query, $temp
);
$response = $this->auth($options);
$result = new ListObjectsV2Result($response);
return $result->getData();
} | Lists the bucket's object list v2 (in ObjectListInfoV2)
@param string $bucket
@param array $options are defined below:
$options = array(
'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000.
'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix.
'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjects will differeniate the object and folder. And it will return subfolder's objects.
'start-after' => The key of returned object must be greater than the 'start-after'.
'continuation-token' => The token from which the list operation must start.
)
Prefix, start-after and continuation-token are for filtering and paging. Their length must be less than 256 bytes
@return ObjectListInfoV2|null
@throws OssException|RequestCore_Exception | listObjectsV2 | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function listObjectVersions($bucket, $options = NULL)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_SUB_RESOURCE] = 'versions';
$query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array();
$options[self::OSS_QUERY_STRING] = array_merge(
$query,
array(self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL,
self::OSS_DELIMITER => isset($options[self::OSS_DELIMITER]) ? $options[self::OSS_DELIMITER] : '/',
self::OSS_PREFIX => isset($options[self::OSS_PREFIX]) ? $options[self::OSS_PREFIX] : '',
self::OSS_MAX_KEYS => isset($options[self::OSS_MAX_KEYS]) ? $options[self::OSS_MAX_KEYS] : self::OSS_MAX_KEYS_VALUE,
self::OSS_KEY_MARKER => isset($options[self::OSS_KEY_MARKER]) ? $options[self::OSS_KEY_MARKER] : '',
self::OSS_VERSION_ID_MARKER => isset($options[self::OSS_VERSION_ID_MARKER]) ? $options[self::OSS_VERSION_ID_MARKER] : '')
);
$response = $this->auth($options);
$result = new ListObjectVersionsResult($response);
return $result->getData();
} | Lists the bucket's object with version information (in ObjectListInfo)
@param string $bucket
@param array $options are defined below:
$options = array(
'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000.
'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix.
'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjectVersions will differeniate the object and folder. And it will return subfolder's objects.
'key-marker' => The key of returned object must be greater than the 'key-marker'.
'version-id-marker' => The version id of returned object must be greater than the 'version-id-marker'.
)
Prefix and marker are for filtering and paging. Their length must be less than 256 bytes
@return ObjectVersionListInfo|null
@throws OssException|RequestCore_Exception | listObjectVersions | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function createObjectDir($bucket, $object, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_OBJECT] = $object . '/';
$options[self::OSS_CONTENT_LENGTH] = array(self::OSS_CONTENT_LENGTH => 0);
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Creates a virtual 'folder' in OSS. The name should not end with '/' because the method will append the name with a '/' anyway.
Internal use only.
@param string $bucket bucket name
@param string $object object name
@param array $options
@return array|null
@throws OssException|RequestCore_Exception | createObjectDir | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function putObject($bucket, $object, $content, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options);
$options[self::OSS_CONTENT] = $content;
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_OBJECT] = $object;
if (!isset($options[self::OSS_LENGTH])) {
$options[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]);
} else {
$options[self::OSS_CONTENT_LENGTH] = $options[self::OSS_LENGTH];
}
$is_check_md5 = $this->isCheckMD5($options);
if ($is_check_md5) {
$content_md5 = base64_encode(md5($content, true));
$options[self::OSS_CONTENT_MD5] = $content_md5;
}
if (!isset($options[self::OSS_CONTENT_TYPE])) {
$options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object);
}
$response = $this->auth($options);
if (isset($options[self::OSS_CALLBACK]) && !empty($options[self::OSS_CALLBACK])) {
$result = new CallbackResult($response);
} else {
$result = new PutSetDeleteResult($response);
}
return $result->getData();
} | Uploads the $content object to OSS.
@param string $bucket bucket name
@param string $object objcet name
@param string $content The content object
@param array $options
@return array|null
@throws OssException|RequestCore_Exception | putObject | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function uploadStream($bucket, $object, $handle, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options);
if (!is_resource($handle)) {
throw new OssException("The handle must be an opened stream");
}
$options[self::OSS_FILE_UPLOAD] = $handle;
if ($this->isCheckMD5($options)) {
rewind($handle);
$ctx = hash_init('md5');
hash_update_stream($ctx, $handle);
$content_md5 = base64_encode(hash_final($ctx, true));
rewind($handle);
$options[self::OSS_CONTENT_MD5] = $content_md5;
}
if (!isset($options[self::OSS_CONTENT_TYPE])) {
$options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object);
}
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_OBJECT] = $object;
if (!isset($options[self::OSS_CONTENT_LENGTH])) {
$stat = fstat($handle);
$options[self::OSS_CONTENT_LENGTH] = $stat[self::OSS_SIZE];
}
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Uploads object from file handle
@param string $bucket bucket name
@param string $object object name
@param resource $handle file handle
@param array $options
@return array|null
@throws OssException|RequestCore_Exception | uploadStream | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function appendObject($bucket, $object, $content, $position, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options);
$options[self::OSS_CONTENT] = $content;
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_POST;
$options[self::OSS_OBJECT] = $object;
$options[self::OSS_SUB_RESOURCE] = 'append';
$options[self::OSS_POSITION] = strval($position);
if (!isset($options[self::OSS_LENGTH])) {
$options[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]);
} else {
$options[self::OSS_CONTENT_LENGTH] = $options[self::OSS_LENGTH];
}
$is_check_md5 = $this->isCheckMD5($options);
if ($is_check_md5) {
$content_md5 = base64_encode(md5($content, true));
$options[self::OSS_CONTENT_MD5] = $content_md5;
}
if (!isset($options[self::OSS_CONTENT_TYPE])) {
$options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object);
}
$response = $this->auth($options);
$result = new AppendResult($response);
return $result->getData();
} | Append the object with the content at the specified position.
The specified position is typically the lengh of the current file.
@param string $bucket bucket name
@param string $object objcet name
@param string $content content to append
@param array $options
@return int|null next append position
@throws OssException|RequestCore_Exception | appendObject | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function appendFile($bucket, $object, $file, $position, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options);
OssUtil::throwOssExceptionWithMessageIfEmpty($file, "file path is invalid");
$file = $this->encodeFilePath($file);
if (!file_exists($file)) {
throw new OssException($file . " file does not exist");
}
$options[self::OSS_FILE_UPLOAD] = $file;
$file_size = sprintf('%u', filesize($options[self::OSS_FILE_UPLOAD]));
$is_check_md5 = $this->isCheckMD5($options);
if ($is_check_md5) {
$content_md5 = base64_encode(md5_file($options[self::OSS_FILE_UPLOAD], true));
$options[self::OSS_CONTENT_MD5] = $content_md5;
}
if (!isset($options[self::OSS_CONTENT_TYPE])) {
$options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object, $file);
}
$options[self::OSS_METHOD] = self::OSS_HTTP_POST;
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_OBJECT] = $object;
$options[self::OSS_CONTENT_LENGTH] = $file_size;
$options[self::OSS_SUB_RESOURCE] = 'append';
$options[self::OSS_POSITION] = strval($position);
$response = $this->auth($options);
$result = new AppendResult($response);
return $result->getData();
} | Append the object with a local file
@param string $bucket bucket name
@param string $object object name
@param string $file The local file path to append with
@param array $options
@return int|null next append position
@throws OssException|RequestCore_Exception | appendFile | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function copyObject($fromBucket, $fromObject, $toBucket, $toObject, $options = NULL)
{
$this->precheckCommon($fromBucket, $fromObject, $options);
$this->precheckCommon($toBucket, $toObject, $options);
$options[self::OSS_BUCKET] = $toBucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_OBJECT] = $toObject;
$param = '/' . $fromBucket . '/' . rawurlencode($fromObject);
if (isset($options[self::OSS_VERSION_ID])) {
$param = $param . '?versionId=' . $options[self::OSS_VERSION_ID];
unset($options[self::OSS_VERSION_ID]);
}
$options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE] = $param;
$response = $this->auth($options);
$result = new CopyObjectResult($response);
return $result->getData();
} | Copy from an existing OSS object to another OSS object. If the target object exists already, it will be overwritten.
@param string $fromBucket Source bucket name
@param string $fromObject Source object name
@param string $toBucket Target bucket name
@param string $toObject Target object name
@param array $options
@return null
@throws OssException|RequestCore_Exception | copyObject | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function getSimplifiedObjectMeta($bucket, $object, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_HEAD;
$options[self::OSS_OBJECT] = $object;
$options[self::OSS_SUB_RESOURCE] = 'objectMeta';
$response = $this->auth($options);
$result = new HeaderResult($response);
return $result->getData();
} | Gets the simplified metadata of a object.
Simplified metadata includes ETag, Size, LastModified.
@param string $bucket bucket name
@param string $object object name
@param string $options Checks out the SDK document for the detail
@return array|null
@throws OssException|RequestCore_Exception | getSimplifiedObjectMeta | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function doesObjectExist($bucket, $object, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_HEAD;
$options[self::OSS_OBJECT] = $object;
$response = $this->auth($options);
$result = new ExistResult($response);
return $result->getData();
} | Checks if the object exists
It's implemented by getObjectMeta().
@param string $bucket bucket name
@param string $object object name
@param array $options
@return bool|null True:object exists; False:object does not exist
@throws OssException|RequestCore_Exception| | doesObjectExist | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function restoreObject($bucket, $object, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options);
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_METHOD] = self::OSS_HTTP_POST;
$options[self::OSS_OBJECT] = $object;
$options[self::OSS_SUB_RESOURCE] = self::OSS_RESTORE;
if (isset($options[self::OSS_RESTORE_CONFIG])) {
$config = $options[self::OSS_RESTORE_CONFIG];
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
$options[self::OSS_CONTENT] = $config->serializeToXml();
}
$response = $this->auth($options);
$result = new PutSetDeleteResult($response);
return $result->getData();
} | Object reading for Archive type
Use Restore to enable the server to perform the thawing task
@param string $bucket bucket name
@param string $object object name
@return array|null
@throws OssException|RequestCore_Exception | restoreObject | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
private function computePartSize($partSize)
{
$partSize = (integer)$partSize;
if ($partSize <= self::OSS_MIN_PART_SIZE) {
$partSize = self::OSS_MIN_PART_SIZE;
} elseif ($partSize > self::OSS_MAX_PART_SIZE) {
$partSize = self::OSS_MAX_PART_SIZE;
}
return $partSize;
} | Gets the part size according to the preferred part size.
If the specified part size is too small or too big, it will return a min part or max part size instead.
Otherwise returns the specified part size.
@param int $partSize
@return int | computePartSize | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function generateMultiuploadParts($file_size, $partSize = 5242880)
{
$i = 0;
$size_count = $file_size;
$values = array();
$partSize = $this->computePartSize($partSize);
while ($size_count > 0) {
$size_count -= $partSize;
$values[] = array(
self::OSS_SEEK_TO => ($partSize * $i),
self::OSS_LENGTH => (($size_count > 0) ? $partSize : ($size_count + $partSize)),
);
$i++;
}
return $values;
} | Computes the parts count, size and start position according to the file size and the part size.
It must be only called by upload_Part().
@param integer $file_size File size
@param integer $partSize part size. Default is 5MB
@return array An array contains key-value pairs--the key is `seekTo`and value is `length`. | generateMultiuploadParts | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function initiateMultipartUpload($bucket, $object, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options);
$options[self::OSS_METHOD] = self::OSS_HTTP_POST;
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_OBJECT] = $object;
$options[self::OSS_SUB_RESOURCE] = 'uploads';
$options[self::OSS_CONTENT] = '';
if (!isset($options[self::OSS_CONTENT_TYPE])) {
$options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object);
}
if (!isset($options[self::OSS_HEADERS])) {
$options[self::OSS_HEADERS] = array();
}
$response = $this->auth($options);
$result = new InitiateMultipartUploadResult($response);
return $result->getData();
} | Initialize a multi-part upload
@param string $bucket bucket name
@param string $object object name
@param array $options Key-Value array
@return string|null returns upload id
@throws OssException|RequestCore_Exception | initiateMultipartUpload | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function uploadPart($bucket, $object, $uploadId, $options = null)
{
$this->precheckCommon($bucket, $object, $options);
$this->precheckParam($options, self::OSS_FILE_UPLOAD, __FUNCTION__);
$this->precheckParam($options, self::OSS_PART_NUM, __FUNCTION__);
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_OBJECT] = $object;
$options[self::OSS_UPLOAD_ID] = $uploadId;
if (isset($options[self::OSS_LENGTH])) {
$options[self::OSS_CONTENT_LENGTH] = $options[self::OSS_LENGTH];
}
$response = $this->auth($options);
$result = new UploadPartResult($response);
return $result->getData();
} | Upload a part in a multiparts upload.
@param string $bucket bucket name
@param string $object object name
@param string $uploadId
@param array $options Key-Value array
@return string|null eTag
@throws OssException|RequestCore_Exception | uploadPart | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function completeMultipartUpload($bucket, $object, $uploadId, $listParts, $options = NULL)
{
$this->precheckCommon($bucket, $object, $options);
$options[self::OSS_METHOD] = self::OSS_HTTP_POST;
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_OBJECT] = $object;
$options[self::OSS_UPLOAD_ID] = $uploadId;
$options[self::OSS_CONTENT_TYPE] = 'application/xml';
if (is_array($listParts)) {
$options[self::OSS_CONTENT] = OssUtil::createCompleteMultipartUploadXmlBody($listParts);
} else {
$options[self::OSS_CONTENT] = "";
}
$response = $this->auth($options);
if (isset($options[self::OSS_CALLBACK]) && !empty($options[self::OSS_CALLBACK])) {
$result = new CallbackResult($response);
} else {
$result = new PutSetDeleteResult($response);
}
return $result->getData();
} | Completes a multiparts upload, after all parts are uploaded.
@param string $bucket bucket name
@param string $object object name
@param string $uploadId uploadId
@param array $listParts array( array("PartNumber"=> int, "ETag"=>string))
@param array $options Key-Value array
@return null
@throws OssException|RequestCore_Exception | completeMultipartUpload | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function listMultipartUploads($bucket, $options = null)
{
$this->precheckCommon($bucket, NULL, $options, false);
$options[self::OSS_METHOD] = self::OSS_HTTP_GET;
$options[self::OSS_BUCKET] = $bucket;
$options[self::OSS_SUB_RESOURCE] = 'uploads';
foreach (array('delimiter', 'key-marker', 'max-uploads', 'prefix', 'upload-id-marker') as $param) {
if (isset($options[$param])) {
$options[self::OSS_QUERY_STRING][$param] = $options[$param];
unset($options[$param]);
}
}
$query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array();
$options[self::OSS_QUERY_STRING] = array_merge(
$query,
array(self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL)
);
$response = $this->auth($options);
$result = new ListMultipartUploadResult($response);
return $result->getData();
} | Lists all ongoing multipart upload events, which means all initialized but not completed or aborted multipart uploads.
@param string $bucket bucket
@param array $options key-value array--expected keys are 'delimiter', 'key-marker', 'max-uploads', 'prefix', 'upload-id-marker'
@return ListMultipartUploadInfo|null
@throws OssException|RequestCore_Exception | listMultipartUploads | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function uploadPartCopy($fromBucket, $fromObject, $toBucket, $toObject, $partNumber, $uploadId, $options = NULL)
{
$this->precheckCommon($fromBucket, $fromObject, $options);
$this->precheckCommon($toBucket, $toObject, $options);
//If $options['isFullCopy'] is not set, copy from the beginning
$start_range = "0";
if (isset($options['start'])) {
$start_range = $options['start'];
}
$end_range = "";
if (isset($options['end'])) {
$end_range = $options['end'];
}
$options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
$options[self::OSS_BUCKET] = $toBucket;
$options[self::OSS_OBJECT] = $toObject;
$options[self::OSS_PART_NUM] = $partNumber;
$options[self::OSS_UPLOAD_ID] = $uploadId;
if (!isset($options[self::OSS_HEADERS])) {
$options[self::OSS_HEADERS] = array();
}
$param = '/' . $fromBucket . '/' . rawurlencode($fromObject);
if (isset($options[self::OSS_VERSION_ID])) {
$param = $param . '?versionId=' . $options[self::OSS_VERSION_ID];
unset($options[self::OSS_VERSION_ID]);
}
$options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE] = $param;
$options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE_RANGE] = "bytes=" . $start_range . "-" . $end_range;
$response = $this->auth($options);
$result = new UploadPartResult($response);
return $result->getData();
} | Copy an existing file as a part
@param string $fromBucket source bucket name
@param string $fromObject source object name
@param string $toBucket target bucket name
@param string $toObject target object name
@param int $partNumber Part number
@param string $uploadId Upload Id
@param array $options Key-Value array---it should have 'start' or 'end' key to specify the range of the source object to copy. If it's not specifed, the whole object is copied.
@return null
@throws OssException|RequestCore_Exception | uploadPartCopy | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function signUrl($bucket, $object, $timeout = 60, $method = self::OSS_HTTP_GET, $options = NULL)
{
$expiration = time() + $timeout;
return $this->generatePresignedUrl($bucket, $object, $expiration, $method, $options);
} | Sign URL with specified expiration time in seconds (timeout) and HTTP method.
The signed URL could be used to access the object directly.
@param string $bucket
@param string $object
@param int $timeout expiration time in seconds.
@param string $method
@param array $options Key-Value array
@return string
@throws OssException | signUrl | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
private function precheckOptions(&$options)
{
OssUtil::validateOptions($options);
if (!$options) {
$options = array();
}
} | validates options. Create a empty array if it's NULL.
@param array $options
@throws OssException | precheckOptions | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
private function precheckObjectExt($object, $strict)
{
$this->precheckObject($object);
if ($strict) {
if (is_string($object) && $object[0] === "?") {
throw new OssException('"' . $object . '"' . ' object name cannot start with `?`');
}
}
} | validates object name start with ? or not
@param $object string
@param $strict boolean
@throws OssException | precheckObjectExt | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
private function precheckCommon($bucket, $object, &$options, $isCheckObject = true)
{
if ($isCheckObject) {
$this->precheckObject($object);
}
$this->precheckOptions($options);
$this->precheckBucket($bucket);
} | Validates bucket,options parameters and optionally validate object parameter.
@param string $bucket
@param string $object
@param array $options
@param bool $isCheckObject | precheckCommon | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
private function getValue($options, $key, $default = NULL, $isCheckEmpty = false, $isCheckBool = false)
{
$value = $default;
if (isset($options[$key])) {
if ($isCheckEmpty) {
if (!empty($options[$key])) {
$value = $options[$key];
}
} else {
$value = $options[$key];
}
unset($options[$key]);
}
if ($isCheckBool) {
if ($value !== true && $value !== false) {
$value = false;
}
}
return $value;
} | Gets value of the specified key from the options
@param array $options
@param string $key
@param string $default
@param bool $isCheckEmpty
@param bool $isCheckBool
@return bool|null | getValue | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function setSignStsInUrl($enable)
{
} | Enaable/disable STS in the URL. This is to determine the $sts value passed from constructor take effect or not.
@param boolean $enable | setSignStsInUrl | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
private function authPrecheckObjectEncoding(&$options)
{
if ($this->checkObjectEncoding !== true) {
return;
}
if (!isset($options[self::OSS_OBJECT])) {
return;
}
try {
$tmp_object = $options[self::OSS_OBJECT];
$encoding = array('UTF-8', 'GB2312', 'GBK');
$encode = mb_detect_encoding($tmp_object, $encoding);
if ($encode === 'UTF-8' || $encode === false) {
return;
}
$tmp_object = iconv($encode, "UTF-8", $tmp_object);
if ($tmp_object === false) {
return;
}
$options[self::OSS_OBJECT] = $tmp_object;
} catch (\Exception $e) {
//IGNORE
}
} | Checks the object's encoding. Convert it to UTF8 if it's in GBK or GB2312
@param mixed $options parameter | authPrecheckObjectEncoding | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
private function authPrecheckAcl($options)
{
if (isset($options[self::OSS_HEADERS][self::OSS_ACL]) && !empty($options[self::OSS_HEADERS][self::OSS_ACL])) {
if (!in_array(strtolower($options[self::OSS_HEADERS][self::OSS_ACL]), self::$OSS_ACL_TYPES)) {
throw new OssException($options[self::OSS_HEADERS][self::OSS_ACL] . ':' . 'acl is invalid(private,public-read,public-read-write)');
}
}
} | Checks if the ACL is one of the 3 predefined one. Throw OSSException if not.
@param $options
@throws OssException | authPrecheckAcl | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
private function generateHostname($bucket)
{
if ($this->hostType === self::OSS_HOST_TYPE_IP || $this->hostType === self::OSS_HOST_TYPE_PATH_STYLE) {
$hostname = $this->hostname;
} elseif ($this->hostType === self::OSS_HOST_TYPE_CNAME) {
$hostname = $this->hostname;
} else {
// Private domain or public domain
$hostname = ($bucket == '') ? $this->hostname : ($bucket . '.') . $this->hostname;
}
return $hostname;
} | Gets the host name for the current request.
It could be either a third level domain (prefixed by bucket name) or second level domain if it's CName or IP
@param $bucket
@return string The host name without the protocol scheem (e.g. https://) | generateHostname | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
private function generatePath($bucket, $object)
{
$paths = array();
// +bucket
if ('' !== $bucket) {
if ($this->hostType === self::OSS_HOST_TYPE_IP || $this->hostType === self::OSS_HOST_TYPE_PATH_STYLE) {
$paths[] = $bucket;
if ('' === $object) {
$paths[] = '';
}
}
}
// + object
if ('' !== $object && '/' !== $object) {
$paths[] = str_replace(array('%2F'), array('/'), rawurlencode($object));
}
return '/' . implode('/', $paths);
} | Gets the Uri path in the current request
@param $bucket
@param $object
@return string return the resource uri. | generatePath | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
private function encodeFilePath($filepath)
{
if ($this->filePathCompatible !== true) {
return $filepath;
}
if (empty($filepath)) {
return $filepath;
}
try {
$encoding = array('UTF-8', 'GB2312', 'GBK');
$encode = mb_detect_encoding($filepath, $encoding);
if ($encode !== 'UTF-8') {
return $filepath;
}
$tmp = iconv($encode, 'GBK', $filepath);
if ($tmp !== false) {
$filepath = $tmp;
}
} catch (\Exception $e) {
//IGNORE
}
return $filepath;
} | Encodes the file path from UTF-8 to GBK.
@param $filepath
@return string | encodeFilePath | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
private function decodeFilePath($filepath)
{
if ($this->filePathCompatible !== true) {
return $filepath;
}
if (empty($filepath)) {
return $filepath;
}
try {
$encoding = array('UTF-8', 'GB2312', 'GBK');
$encode = mb_detect_encoding($filepath, $encoding);
if ($encode === 'UTF-8' || $encode === false) {
return $filepath;
}
$tmp = iconv($encode, 'UTF-8', $filepath);
if ($tmp !== false) {
$filepath = $tmp;
}
} catch (\Exception $e) {
//IGNORE
}
return $filepath;
} | Decodes the file path from GBK to UTF-8.
@param $filepath
@return string | decodeFilePath | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public static function checkEnv()
{
if (function_exists('get_loaded_extensions')) {
//Test curl extension
$enabled_extension = array("curl");
$extensions = get_loaded_extensions();
if ($extensions) {
foreach ($enabled_extension as $item) {
if (!in_array($item, $extensions)) {
throw new OssException("Extension {" . $item . "} is not installed or not enabled, please check your php env.");
}
}
} else {
throw new OssException("function get_loaded_extensions not found.");
}
} else {
throw new OssException('Function get_loaded_extensions has been disabled, please check php config.');
}
} | Check if all dependent extensions are installed correctly.
For now only "curl" is needed.
@throws OssException | checkEnv | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function setTimeout($timeout)
{
$this->timeout = $timeout;
} | Sets the http's timeout (in seconds)
@param int $timeout | setTimeout | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function setConnectTimeout($connectTimeout)
{
$this->connectTimeout = $connectTimeout;
} | Sets the http's connection timeout (in seconds)
@param int $connectTimeout | setConnectTimeout | php | aliyun/aliyun-oss-php-sdk | src/OSS/OssClient.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/OssClient.php | MIT |
public function __construct($key, $secret, $token = null)
{
if (empty($key)) {
throw new OssException("access key id is empty");
}
if (empty($secret)) {
throw new OssException("access key secret is empty");
}
$this->key = trim($key);
$this->secret = trim($secret);
$this->token = $token;
} | Constructor a new BasicOSSCredentials object, with the specified OSS
access key and OSS secret key
@param string $key OSS access key ID
@param string $secret OSS secret access key
@param string $token Security token to use | __construct | php | aliyun/aliyun-oss-php-sdk | src/OSS/Credentials/Credentials.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Credentials/Credentials.php | MIT |
public function __construct($key, $secret, $token = null)
{
$this->credentials = new Credentials($key, $secret, $token);
} | Constructs a new StaticCredentialsProvider object, with the specified OSS
access key and OSS secret key
@param string $key OSS access key ID
@param string $secret OSS access key secret
@param string $token Security token to use | __construct | php | aliyun/aliyun-oss-php-sdk | src/OSS/Credentials/StaticCredentialsProvider.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Credentials/StaticCredentialsProvider.php | MIT |
public function __construct($header, $body, $status = null)
{
$this->header = $header;
$this->body = $body;
$this->status = $status;
return $this;
} | Construct a new instance of this class.
@param array $header (Required) Associative array of HTTP headers (typically returned by <RequestCore::get_response_header()>).
@param string $body (Required) XML-formatted response from OSS.
@param integer $status (Optional) HTTP response status code from the request.
@return Mixed Contains an <php:array> `header` property (HTTP headers as an associative array), a <php:SimpleXMLElement> or <php:string> `body` property, and an <php:integer> `status` code. | __construct | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/ResponseCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/ResponseCore.php | MIT |
public function __construct($url = null, $proxy = null, $helpers = null)
{
// Set some default values.
$this->request_url = $url;
$this->method = self::HTTP_GET;
$this->request_headers = array();
$this->request_body = '';
// Set a new Request class if one was set.
if (isset($helpers['request']) && !empty($helpers['request'])) {
$this->request_class = $helpers['request'];
}
// Set a new Request class if one was set.
if (isset($helpers['response']) && !empty($helpers['response'])) {
$this->response_class = $helpers['response'];
}
if ($proxy) {
$this->set_proxy($proxy);
}
return $this;
} | Construct a new instance of this class.
@param string $url (Optional) The URL to request or service endpoint to query.
@param string $proxy (Optional) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port`
@param array $helpers (Optional) An associative array of classnames to use for request, and response functionality. Gets passed in automatically by the calling class.
@return $this A reference to the current instance. | __construct | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/RequestCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php | MIT |
public function __destruct()
{
if (isset($this->read_file) && isset($this->read_stream)) {
fclose($this->read_stream);
}
if (isset($this->write_file) && isset($this->write_stream)) {
fclose($this->write_stream);
}
return $this;
} | Destruct the instance. Closes opened file handles.
@return $this A reference to the current instance. | __destruct | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/RequestCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php | MIT |
public function set_credentials($user, $pass)
{
$this->username = $user;
$this->password = $pass;
return $this;
} | Set the credentials to use for authentication.
@param string $user (Required) The username to authenticate with.
@param string $pass (Required) The password to authenticate with.
@return $this A reference to the current instance. | set_credentials | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/RequestCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php | MIT |
public function add_header($key, $value)
{
$this->request_headers[$key] = $value;
return $this;
} | Add a custom HTTP header to the cURL request.
@param string $key (Required) The custom HTTP header to set.
@param mixed $value (Required) The value to assign to the custom HTTP header.
@return $this A reference to the current instance. | add_header | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/RequestCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php | MIT |
public function remove_header($key)
{
if (isset($this->request_headers[$key])) {
unset($this->request_headers[$key]);
}
return $this;
} | Remove an HTTP header from the cURL request.
@param string $key (Required) The custom HTTP header to set.
@return $this A reference to the current instance. | remove_header | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/RequestCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php | MIT |
public function set_method($method)
{
$this->method = strtoupper($method);
return $this;
} | Set the method type for the request.
@param string $method (Required) One of the following constants: <HTTP_GET>, <HTTP_POST>, <HTTP_PUT>, <HTTP_HEAD>, <HTTP_DELETE>.
@return $this A reference to the current instance. | set_method | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/RequestCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php | MIT |
public function set_useragent($ua)
{
$this->useragent = $ua;
return $this;
} | Set a custom useragent string for the class.
@param string $ua (Required) The useragent string to use.
@return $this A reference to the current instance. | set_useragent | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/RequestCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php | MIT |
public function set_body($body)
{
$this->request_body = $body;
return $this;
} | Set the body to send in the request.
@param string $body (Required) The textual content to send along in the body of the request.
@return $this A reference to the current instance. | set_body | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/RequestCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php | MIT |
public function set_request_url($url)
{
$this->request_url = $url;
return $this;
} | Set the URL to make the request to.
@param string $url (Required) The URL to make the request to.
@return $this A reference to the current instance. | set_request_url | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/RequestCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php | MIT |
public function set_curlopts($curlopts)
{
$this->curlopts = $curlopts;
return $this;
} | Set additional CURLOPT settings. These will merge with the default settings, and override if
there is a duplicate.
@param array $curlopts (Optional) A set of key-value pairs that set `CURLOPT` options. These will merge with the existing CURLOPTs, and ones passed here will override the defaults. Keys should be the `CURLOPT_*` constants, not strings.
@return $this A reference to the current instance. | set_curlopts | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/RequestCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php | MIT |
public function set_read_stream_size($size)
{
$this->read_stream_size = $size;
return $this;
} | Set the length in bytes to read from the stream while streaming up.
@param integer $size (Required) The length in bytes to read from the stream.
@return $this A reference to the current instance. | set_read_stream_size | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/RequestCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php | MIT |
public function set_read_stream($resource, $size = null)
{
if (!isset($size) || $size < 0) {
$stats = fstat($resource);
if ($stats && $stats['size'] >= 0) {
$position = ftell($resource);
if ($position !== false && $position >= 0) {
$size = $stats['size'] - $position;
}
}
}
$this->read_stream = $resource;
return $this->set_read_stream_size($size);
} | Set the resource to read from while streaming up. Reads the stream from its current position until
EOF or `$size` bytes have been read. If `$size` is not given it will be determined by <php:fstat()> and
<php:ftell()>.
@param resource $resource (Required) The readable resource to read from.
@param integer $size (Optional) The size of the stream to read.
@return $this A reference to the current instance. | set_read_stream | php | aliyun/aliyun-oss-php-sdk | src/OSS/Http/RequestCore.php | https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.