Add deploy ci (#18)
parent
4f3a179ad1
commit
06aac2e495
@ -0,0 +1,6 @@
|
||||
/.git
|
||||
/.github
|
||||
/.distignore
|
||||
/sdk/composer.lock
|
||||
/sdk/vendor/aliyuncs/oss-sdk-php/samples/
|
||||
/sdk/vendor/aliyuncs/oss-sdk-php/tests/
|
@ -0,0 +1,44 @@
|
||||
name: Deploy to WordPress.org
|
||||
on:
|
||||
pull_request:
|
||||
release:
|
||||
types: [ published ]
|
||||
jobs:
|
||||
tag:
|
||||
name: New release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '7.0'
|
||||
tools: composer
|
||||
- name: Build
|
||||
run: |
|
||||
composer install -o --no-dev
|
||||
working-directory: sdk
|
||||
- name: Set Version
|
||||
if: github.event_name == 'pull_request'
|
||||
run: |
|
||||
echo "VERSION=ci" >> $GITHUB_ENV
|
||||
- name: WordPress Plugin Deploy
|
||||
id: deploy
|
||||
uses: 10up/action-wordpress-plugin-deploy@stable
|
||||
with:
|
||||
dry-run: ${{ github.event_name == 'pull_request' }}
|
||||
generate-zip: ${{ github.event_name == 'release' }}
|
||||
env:
|
||||
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
|
||||
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
|
||||
SLUG: oss-aliyun
|
||||
- name: Upload release asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
if: github.event_name == 'release'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_path: ${{ steps.deploy.outputs.zip-path }}
|
||||
asset_name: ${{ github.event.repository.name }}.zip
|
||||
asset_content_type: application/zip
|
@ -1,70 +0,0 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c875f4be4bdd250755929eff026f0525",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aliyuncs/oss-sdk-php",
|
||||
"version": "v2.4.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/aliyun/aliyun-oss-php-sdk.git",
|
||||
"reference": "0c9d902c33847c07efc66c4cdf823deaea8fc2b6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/0c9d902c33847c07efc66c4cdf823deaea8fc2b6",
|
||||
"reference": "0c9d902c33847c07efc66c4cdf823deaea8fc2b6",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||
"preferred": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "*",
|
||||
"satooshi/php-coveralls": "*"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"OSS\\": "src/OSS"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Aliyuncs",
|
||||
"homepage": "http://www.aliyun.com"
|
||||
}
|
||||
],
|
||||
"description": "Aliyun OSS SDK for PHP",
|
||||
"homepage": "http://www.aliyun.com/product/oss/",
|
||||
"support": {
|
||||
"issues": "https://github.com/aliyun/aliyun-oss-php-sdk/issues",
|
||||
"source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.4.2"
|
||||
},
|
||||
"time": "2021-06-04T06:55:06+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.0.0"
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
coverage_clover: coverage.xml
|
||||
json_path: coverage.json
|
@ -1,8 +0,0 @@
|
||||
vendor
|
||||
composer.lock
|
||||
doc
|
||||
output
|
||||
.idea
|
||||
.buildpath
|
||||
.project
|
||||
.settings
|
@ -1,21 +0,0 @@
|
||||
language: php
|
||||
php:
|
||||
- 7.1
|
||||
- 7.0
|
||||
- 5.6
|
||||
- 5.5
|
||||
- 5.4
|
||||
install:
|
||||
- composer self-update
|
||||
- composer install --no-interaction
|
||||
script:
|
||||
- php vendor/bin/phpunit
|
||||
after_success:
|
||||
- php vendor/bin/coveralls -v
|
||||
env:
|
||||
global:
|
||||
- secure: SzmQ854lQmhV6ZkAG7lQNTY3CkazrXnDSb6VMwPU/sdaLGxPO159AW3fJS5d0sO/XN1P8x5WNkoA4i9soDlLBRibEEISNUM/2EMnpszsRymZ9o97PrS2IgORXTUL/OF+rpATzyNVB2p+2l9hBLiGf17exMSA5iOeY7W6E+VKPGi8TFykgbGUnLKU0h1hV3rzmtfGjOXcSpvYU/hxeZD/J/+6m5Gic9b/pNS+AbfTj7Y7Ru9tNsnyUP29V/vtEYtpQir3ZxQiSiUv9idybgGnJBOMYydJofb/mpFYHhYLSWqtMKGNLpeawmqs4z8S1Tvx5U5uzW5+h/mpzhvBaFlWGpm8t89BQxun5LVX5NiYCrV7TqaLitGp1cSpMjMDnrnSTNzk1exVz+rWZZcWS7yB9ULYA681GA8StXWk167qB7Y30iK1dFK3+2mDN2cEY+qLs8+bupDowQ4eOM+eqfhxX8F8+ouKcKomETsjiIwL+CUsIe6wjvnYFWb1YlRhbsI75bblHApflohnt6gVSJ78ZPqID+u2oUMjmIWXLTnRR2Y2tgEW8uqHeIoQ8BBntLdQDmv0BO4FpnGQIwrUUwQYeNzEM0DOr3hWZhyDR6Xvl+9H0l52xjANaSqpuTZfC3zmeFTG7kIjydvxNePRrony6XAawL9BvI7aKWuVF6YVjPM=
|
||||
- secure: nEhsU8aUQqsAJeuger+boh51oTpeo4YNG7vUWbKxdwVDIrcLb+l7r7RvTlxU7mt8IZTWwicgri18mh+Wi04BwX4ulBA1SCs8jPbL51KEo5izoDGGtLSd2fuPHdslYSrwagrvq90EPnDT/7fHWn/TAoT+rueZzjNyCu5IGSgL3GnXaUThsJ82NMePL2YRdP4Q1qmtZPRFBOkOQ6F0heuV8fw8sLyTO3txaCQum9YneGxrWxOl/E8zB0qtlnPwLE8ogaHZMQh2/jThmTbI5UqwRTxV4f0qoD5eJYH+j0fslsSAjsg/HPnSuVcnccK3zSU+s2sV4dPCcISzECJvZEObwipfxOGhdqt5gMcxHhn8qVsbT97iIh106pG/BJCDgQd2EeVW8WfCi6cCuCKIMipvVkMypkmjQHWU1XaqPzILl7g5diW9Ctp2C4Akq5dYdrdu8IrnVK1ShtkQVaWU+S/Bht8VU5gYP7olPW/GdTz7sceU1NOIC4NPXqmWKbfavR98U5dkHMLMvzABYL1Q87h+KhPD1c14NUyw3YENUW7REiF/X5lERRm5H0kJ/1JqAa+AgeHQEGmPVuZV2s/na4b0S1479QRVmSM/6ZzXQpU+Y8jCRfETpUFA4S331369kirHgCqDlxyIntuEKrzivD02/O+5C3eJ0WHRz6QsN2/R4qg=
|
||||
- secure: ZTvzNXEZP4efl+a/3VGMmdabfUQp83v5/lecMns039Ro7UuZYPdtbPtpPnpjaTI6Htd22A4Rva5BU/3JCQJAyQvpbKNn5sGou2SmfQu3o0SyhggSB7gWjYAf707aW1j4bHYfP8IjDS5NjuVk3AqXeNSUuLRUXRmwSOB0lSYiRhiTJY+pUdBl382Hx4NbhIU/gmOzRoJCs7coTip8IURXYEHPi5dnDWluajxI+TgNXFccSgEleeQDJajYgXmpLb2EhSj8piipOnVgaCEE5bh5fbp32024Qq38SGHKcbfnwj2IInpZpZESJknRKoqAlFjdOJhork82dBcvAr5JxCBZKx5IuwXcTjxkQ6tRtBeqhPLPFuX3MQ8WrtU+wniPM0RCH/VoFkUKO7JGQDwmoi2AKago4PsuDs4P6Y6CeuOVpcso731GwwMNhIJcyrJJivXprQNEGsEw+9wLjU1qNYs6IIA3S/gPzFrNbdX5Wf8vxt0vLpgYvBNtPnLMejMtknuyfVzf5iKuVVoGPDTEz+ajs06+jfoPfm/4sLTaLghuVH7Adm74OpF769JQNnQYKwJuu4bNlcbLJChulCEMBOx7myqo/9O6RCTuqzHaGmVWNot4RGqRFHgJGl/JJf0WpAVitbhbRH3kGoyKb6jFM74CJbPsE7OORlJLDC3cdD3C8Pk=
|
||||
- secure: Qr5NR4CVzBKCQgRgMH0x772TPJ1+brx3UCvtRNu8fi4j3p8bz+HDMjBaBDSFmEB09nunLI55/8mj88/5GXmnpFs8+CPTkcW+QZOcxg3cxpI4SNmxoB12/ZawlFHAqSUaRRE7RUWVkY3KL8tIGjEZcFyUBQ1DVNX3OMpiKs3NLtHa7oUIknyBxdSokm4kpLhSXYe7WmO0vhuZbMZE0S1EISToiBS6AdhGUEbTLJ/vNsIDY07fu6+Vh3HxVbyUFPqUZGlkZpQ+2xMJ3kiqPBMrXtRF/IhhPjORDil6Ns9SQ8/AAlaCddvYvRaT4Pjv2/aX+t3l28qI1qmryPtWXpce5UXecWGYqdRpSJc6Y/pEt4m4FeeGoEFWnSPGIs7FRmeiis8q2rojGZ18i4vI/k4iHmqEBnTlMp3SWnRb9L1adJ8ZAWln8aC88gkQXm67w7+1CxLycerbYj9H1ugqHENuHcxv4uHUcZgEENX3EWatu8i9+K2IUuU/2zcmpu7qtsziYcoyW8DOOmYpJfXGMLtmF9+pqp/Tp6i0tltFSEfmY3N8o7xvv3enLvFHsjL+3ElFdd1blUPSrvZJHgA9M3lJ+QF1RJZCpJqgPlQ0XOZK1Bf4P46zpEj01wKaK4JQrkLPRXhbBOuIJn5O6WlFJyPX4+SaBfwTzb4AvM4aUg2TgTg=
|
||||
- secure: Inw5ftA8fxvhMHRZwoZzATxn4WICJsCq7ZX4y2gI+b/8u0JQIsbLgY9WTYV+XdSxOoNwuVa1oUxEWI0aDORtXKC3XaIXXKrwndag0zxS77JEYwWvQsjM7BhEbF7MF7MYk8rRXpn6mbfGAT/NfqEOx91RCY8UKeMzD0oPkpkBnJ9Ekuod6JBBq+7j3v4mYUItA8pxvw7b4Pdd4z2xzjgOwNhJYMOCpts50DWZI+WXj0HvTYaMXe5mJJtORK5lsr0a9cbsBqAzE6l+3zGI8XkgHn130ux5XH3DE7hZBeti3ZNaO3d2Vv+496/1EObG0rSFk+z3dmNKqjMz4nh3bYIkdLMegwmgCWs2mvQhkwYhzmnPRHVSERrgZjSWnuKn2PKnBar6tui9KaLNgpo2j3jWpwMLJ3bGAfE5JtMppxAxNqj/q+YB2UZo7Mn7EDjkTDjgxCuazTJwWqH7xxCOykWPABBI17P3JaOXQJEK39LavpfSMm3kdmU0ocpUs7FniLuFm6xL71VxY1wHG10yskczEcFHZ3iyIyGM+xum4vbt5y6Yg+zfdExYQsbrxHDDZ3HbHY3tEU0WhM55vrC42NIXRWqXqJ8OAxpl4nivfx96eoBAThiUU9xXtZmh7WRFVYsstoGtxZwfk5+bi+oeVO9kih4xabwbgHgL9BTc1TR1C4U=
|
@ -1,21 +0,0 @@
|
||||
#The MIT License (MIT)
|
||||
|
||||
Copyright (c) ali-sdk and other contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -1,150 +0,0 @@
|
||||
# Alibaba Cloud OSS SDK for PHP
|
||||
|
||||
[![Latest Stable Version](https://poser.pugx.org/aliyuncs/oss-sdk-php/v/stable)](https://packagist.org/packages/aliyuncs/oss-sdk-php)
|
||||
[![Build Status](https://travis-ci.org/aliyun/aliyun-oss-php-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-php-sdk)
|
||||
[![Coverage Status](https://coveralls.io/repos/github/aliyun/aliyun-oss-php-sdk/badge.svg?branch=master)](https://coveralls.io/github/aliyun/aliyun-oss-php-sdk?branch=master)
|
||||
|
||||
## [README of Chinese](https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/README-CN.md)
|
||||
|
||||
## Overview
|
||||
|
||||
Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring a massive capacity, security, a low cost, and high reliability. You can upload and download data on any application anytime and anywhere by calling APIs, and perform simple management of data through the web console. The OSS can store any type of files and therefore applies to various websites, development enterprises and developers.
|
||||
|
||||
|
||||
## Run environment
|
||||
- PHP 5.3+.
|
||||
- cURL extension.
|
||||
|
||||
Tips:
|
||||
|
||||
- In Ubuntu, you can use the ***apt-get*** package manager to install the *PHP cURL extension*: `sudo apt-get install php5-curl`.
|
||||
|
||||
## Install OSS PHP SDK
|
||||
|
||||
- If you use the ***composer*** to manage project dependencies, run the following command in your project's root directory:
|
||||
|
||||
composer require aliyuncs/oss-sdk-php
|
||||
|
||||
You can also declare the dependency on Alibaba Cloud OSS SDK for PHP in the `composer.json` file.
|
||||
|
||||
"require": {
|
||||
"aliyuncs/oss-sdk-php": "~2.0"
|
||||
}
|
||||
|
||||
Then run `composer install` to install the dependency. After the Composer Dependency Manager is installed, import the dependency in your PHP code:
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
- You can also directly download the packaged [PHAR File][releases-page], and
|
||||
introduce the file to your code:
|
||||
|
||||
require_once '/path/to/oss-sdk-php.phar';
|
||||
|
||||
- Download the SDK source code, and introduce the `autoload.php` file under the SDK directory to your code:
|
||||
|
||||
require_once '/path/to/oss-sdk/autoload.php';
|
||||
|
||||
## Quick use
|
||||
|
||||
### Common classes
|
||||
|
||||
| Class | Explanation |
|
||||
|:------------------|:------------------------------------|
|
||||
|OSS\OssClient | OSS client class. An OssClient instance can be used to call the interface. |
|
||||
|OSS\Core\OssException |OSS Exception class . You only need to pay attention to this exception when you use the OssClient. |
|
||||
|
||||
### Initialize an OssClient
|
||||
|
||||
The SDK's operations for the OSS are performed through the OssClient class. The code below creates an OssClient object:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$accessKeyId = "<AccessKeyID that you obtain from OSS>";
|
||||
$accessKeySecret = "<AccessKeySecret that you obtain from OSS>";
|
||||
$endpoint = "<Domain that you select to access an OSS data center, such as "oss-cn-hangzhou.aliyuncs.com>";
|
||||
try {
|
||||
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
|
||||
} catch (OssException $e) {
|
||||
print $e->getMessage();
|
||||
}
|
||||
```
|
||||
|
||||
### Operations on objects
|
||||
|
||||
Objects are the most basic data units on the OSS. You can simply consider objects as files. The following code uploads an object:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$bucket= "<Name of the bucket in use. Pay attention to naming conventions>";
|
||||
$object = "<Name of the object in use. Pay attention to naming conventions>";
|
||||
$content = "Hello, OSS!"; // Content of the uploaded file
|
||||
try {
|
||||
$ossClient->putObject($bucket, $object, $content);
|
||||
} catch (OssException $e) {
|
||||
print $e->getMessage();
|
||||
}
|
||||
```
|
||||
|
||||
### Operations on buckets
|
||||
|
||||
Buckets are the space that you use to manage the stored objects. It is an object management unit for users. Each object must belong to a bucket. You can create a bucket with the following code:
|
||||
|
||||
```php
|
||||
<?php
|
||||
$bucket= "<Name of the bucket in use. Pay attention to naming conventions>";
|
||||
try {
|
||||
$ossClient->createBucket($bucket);
|
||||
} catch (OssException $e) {
|
||||
print $e->getMessage();
|
||||
}
|
||||
```
|
||||
|
||||
### Handle returned results
|
||||
|
||||
The OssClient provides the following two types of returned data from interfaces:
|
||||
|
||||
- Put and Delete interfaces: The *PUT* and *DELETE* operations are deemed successful if *null* is returned by the interfaces without *OSSException*.
|
||||
- Get and List interfaces: The *GET* and *LIST* operations are deemed successful if the desired data is returned by the interfaces without *OSSException*. For example,
|
||||
|
||||
```php
|
||||
<?php
|
||||
$bucketListInfo = $ossClient->listBuckets();
|
||||
$bucketList = $bucketListInfo->getBucketList();
|
||||
foreach($bucketList as $bucket) {
|
||||
print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreateDate() . "\n");
|
||||
}
|
||||
```
|
||||
In the above code, $bucketListInfo falls into the 'OSS\Model\BucketListInfo' data type.
|
||||
|
||||
|
||||
### Run a sample project
|
||||
|
||||
- Modify `samples/Config.php` to complete the configuration information.
|
||||
- Run `cd samples/ && php RunAll.php`.
|
||||
|
||||
### Run a unit test
|
||||
|
||||
- Run `composer install` to download the dependent libraries.
|
||||
- Set the environment variable.
|
||||
|
||||
export OSS_ACCESS_KEY_ID=access-key-id
|
||||
export OSS_ACCESS_KEY_SECRET=access-key-secret
|
||||
export OSS_ENDPOINT=endpoint
|
||||
export OSS_BUCKET=bucket-name
|
||||
|
||||
- Run `php vendor/bin/phpunit`
|
||||
|
||||
## License
|
||||
|
||||
- MIT
|
||||
|
||||
## Contact us
|
||||
|
||||
- [Alibaba Cloud OSS official website](http://oss.aliyun.com).
|
||||
- [Alibaba Cloud OSS official forum](http://bbs.aliyun.com).
|
||||
- [Alibaba Cloud OSS official documentation center](http://www.aliyun.com/product/oss#Docs).
|
||||
- Alibaba Cloud official technical support: [Submit a ticket](https://workorder.console.aliyun.com/#/ticket/createIndex).
|
||||
|
||||
[releases-page]: https://github.com/aliyun/aliyun-oss-php-sdk/releases
|
||||
[phar-composer]: https://github.com/clue/phar-composer
|
||||
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
function classLoader($class)
|
||||
{
|
||||
$path = str_replace('\\', DIRECTORY_SEPARATOR, $class);
|
||||
$file = __DIR__ . DIRECTORY_SEPARATOR .'src'. DIRECTORY_SEPARATOR . $path . '.php';
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
}
|
||||
}
|
||||
spl_autoload_register('classLoader');
|
@ -1,13 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
# Remove dev deps to reduce phar size
|
||||
rm -rf composer.lock vendor/
|
||||
|
||||
# Generate composer.lock
|
||||
composer install --no-dev
|
||||
|
||||
# Find SDK version
|
||||
version=$(grep 'const OSS_VERSION' src/OSS/OssClient.php | grep -oE '[0-9.]+')
|
||||
|
||||
# Build phar
|
||||
phar-composer build . aliyun-oss-php-sdk-$version.phar
|
@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "aliyuncs/oss-sdk-php",
|
||||
"description": "Aliyun OSS SDK for PHP",
|
||||
"homepage": "http://www.aliyun.com/product/oss/",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Aliyuncs",
|
||||
"homepage": "http://www.aliyun.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php":">=5.3"
|
||||
},
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit": "*",
|
||||
"satooshi/php-coveralls": "*"
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"autoload": {
|
||||
"psr-4": {"OSS\\": "src/OSS"}
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 21 KiB |
@ -1,3 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
|
||||
<phpunit>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">./src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<logging>
|
||||
<log type="coverage-clover" target="coverage.xml" />
|
||||
</logging>
|
||||
<testsuites>
|
||||
<testsuite name="FunctionTest">
|
||||
<directory>./tests</directory>
|
||||
<exclude>./tests/OSS/Tests/BucketCnameTest.php</exclude>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
@ -1,168 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Common.php';
|
||||
|
||||
use OSS\OssClient;
|
||||
use OSS\Core\OssException;
|
||||
|
||||
$ossClient = Common::getOssClient();
|
||||
if (is_null($ossClient)) exit(1);
|
||||
$bucket = Common::getBucketName();
|
||||
|
||||
//******************************* Simple Usage****************************************************************
|
||||
|
||||
// Create a bucket
|
||||
$ossClient->createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
|
||||
Common::println("bucket $bucket created");
|
||||
|
||||
// Check whether a bucket exists
|
||||
$doesExist = $ossClient->doesBucketExist($bucket);
|
||||
Common::println("bucket $bucket exist? " . ($doesExist ? "yes" : "no"));
|
||||
|
||||
// Get the bucket list
|
||||
$bucketListInfo = $ossClient->listBuckets();
|
||||
|
||||
// Set bucket ACL
|
||||
$ossClient->putBucketAcl($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
|
||||
Common::println("bucket $bucket acl put");
|
||||
// Get bucket ACL
|
||||
$acl = $ossClient->getBucketAcl($bucket);
|
||||
Common::println("bucket $bucket acl get: " . $acl);
|
||||
|
||||
|
||||
//******************************* For complete usage, see the following functions ****************************************************
|
||||
|
||||
createBucket($ossClient, $bucket);
|
||||
doesBucketExist($ossClient, $bucket);
|
||||
deleteBucket($ossClient, $bucket);
|
||||
putBucketAcl($ossClient, $bucket);
|
||||
getBucketAcl($ossClient, $bucket);
|
||||
listBuckets($ossClient);
|
||||
|
||||
/**
|
||||
* Create a new bucket
|
||||
* acl indicates the access permission of a bucket, including: private, public-read-only/private-read-write, and public read-write.
|
||||
* Private indicates that only the bucket owner or authorized users can access the data..
|
||||
* The three permissions are separately defined by (OssClient::OSS_ACL_TYPE_PRIVATE,OssClient::OSS_ACL_TYPE_PUBLIC_READ, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE)
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket Name of the bucket to create
|
||||
* @return null
|
||||
*/
|
||||
function createBucket($ossClient, $bucket)
|
||||
{
|
||||
try {
|
||||
$ossClient->createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a bucket exists.
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
*/
|
||||
function doesBucketExist($ossClient, $bucket)
|
||||
{
|
||||
try {
|
||||
$res = $ossClient->doesBucketExist($bucket);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
if ($res === true) {
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
} else {
|
||||
print(__FUNCTION__ . ": FAILED" . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a bucket. If the bucket is not empty, the deletion fails.
|
||||
* A bucket which is not empty indicates that it does not contain any objects or parts that are not completely uploaded during multipart upload
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket Name of the bucket to delete
|
||||
* @return null
|
||||
*/
|
||||
function deleteBucket($ossClient, $bucket)
|
||||
{
|
||||
try {
|
||||
$ossClient->deleteBucket($bucket);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bucket ACL
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function putBucketAcl($ossClient, $bucket)
|
||||
{
|
||||
$acl = OssClient::OSS_ACL_TYPE_PRIVATE;
|
||||
try {
|
||||
$ossClient->putBucketAcl($bucket, $acl);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get bucket ACL
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function getBucketAcl($ossClient, $bucket)
|
||||
{
|
||||
try {
|
||||
$res = $ossClient->getBucketAcl($bucket);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
print('acl: ' . $res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List all buckets
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @return null
|
||||
*/
|
||||
function listBuckets($ossClient)
|
||||
{
|
||||
$bucketList = null;
|
||||
try {
|
||||
$bucketListInfo = $ossClient->listBuckets();
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
$bucketList = $bucketListInfo->getBucketList();
|
||||
foreach ($bucketList as $bucket) {
|
||||
print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreatedate() . "\n");
|
||||
}
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Common.php';
|
||||
|
||||
use OSS\OssClient;
|
||||
use OSS\Core\OssException;
|
||||
use OSS\Model\CorsConfig;
|
||||
use OSS\Model\CorsRule;
|
||||
|
||||
$ossClient = Common::getOssClient();
|
||||
if (is_null($ossClient)) exit(1);
|
||||
$bucket = Common::getBucketName();
|
||||
|
||||
|
||||
//******************************* Simple usage****************************************************************
|
||||
|
||||
// Set cors configuration
|
||||
$corsConfig = new CorsConfig();
|
||||
$rule = new CorsRule();
|
||||
$rule->addAllowedHeader("x-oss-header");
|
||||
$rule->addAllowedOrigin("http://www.b.com");
|
||||
$rule->addAllowedMethod("POST");
|
||||
$rule->setMaxAgeSeconds(10);
|
||||
$corsConfig->addRule($rule);
|
||||
$ossClient->putBucketCors($bucket, $corsConfig);
|
||||
Common::println("bucket $bucket corsConfig created:" . $corsConfig->serializeToXml());
|
||||
|
||||
// Get cors configuration
|
||||
$corsConfig = $ossClient->getBucketCors($bucket);
|
||||
Common::println("bucket $bucket corsConfig fetched:" . $corsConfig->serializeToXml());
|
||||
|
||||
// Delete cors configuration
|
||||
$ossClient->deleteBucketCors($bucket);
|
||||
Common::println("bucket $bucket corsConfig deleted");
|
||||
|
||||
//******************************* For complete usage, see the following functions *****************************************************
|
||||
|
||||
putBucketCors($ossClient, $bucket);
|
||||
getBucketCors($ossClient, $bucket);
|
||||
deleteBucketCors($ossClient, $bucket);
|
||||
getBucketCors($ossClient, $bucket);
|
||||
|
||||
/**
|
||||
* Set bucket cores
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function putBucketCors($ossClient, $bucket)
|
||||
{
|
||||
$corsConfig = new CorsConfig();
|
||||
$rule = new CorsRule();
|
||||
$rule->addAllowedHeader("x-oss-header");
|
||||
$rule->addAllowedOrigin("http://www.b.com");
|
||||
$rule->addAllowedMethod("POST");
|
||||
$rule->setMaxAgeSeconds(10);
|
||||
$corsConfig->addRule($rule);
|
||||
|
||||
try {
|
||||
$ossClient->putBucketCors($bucket, $corsConfig);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and print the cors configuration of a bucket
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function getBucketCors($ossClient, $bucket)
|
||||
{
|
||||
$corsConfig = null;
|
||||
try {
|
||||
$corsConfig = $ossClient->getBucketCors($bucket);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
print($corsConfig->serializeToXml() . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all cors configuraiton of a bucket
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function deleteBucketCors($ossClient, $bucket)
|
||||
{
|
||||
try {
|
||||
$ossClient->deleteBucketCors($bucket);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
||||
|
@ -1,109 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Common.php';
|
||||
|
||||
use OSS\OssClient;
|
||||
use OSS\Core\OssException;
|
||||
use OSS\Model\LifecycleAction;
|
||||
use OSS\Model\LifecycleConfig;
|
||||
use OSS\Model\LifecycleRule;
|
||||
|
||||
$bucket = Common::getBucketName();
|
||||
$ossClient = Common::getOssClient();
|
||||
if (is_null($ossClient)) exit(1);
|
||||
|
||||
//******************************* Simple Usage *******************************************************
|
||||
|
||||
// Set lifecycle configuration
|
||||
$lifecycleConfig = new LifecycleConfig();
|
||||
$actions = array();
|
||||
$actions[] = new LifecycleAction("Expiration", "Days", 3);
|
||||
$lifecycleRule = new LifecycleRule("delete obsoleted files", "obsoleted/", "Enabled", $actions);
|
||||
$lifecycleConfig->addRule($lifecycleRule);
|
||||
$ossClient->putBucketLifecycle($bucket, $lifecycleConfig);
|
||||
Common::println("bucket $bucket lifecycleConfig created:" . $lifecycleConfig->serializeToXml());
|
||||
|
||||
// Get lifecycle configuration
|
||||
$lifecycleConfig = $ossClient->getBucketLifecycle($bucket);
|
||||
Common::println("bucket $bucket lifecycleConfig fetched:" . $lifecycleConfig->serializeToXml());
|
||||
|
||||
// Delete bucket lifecycle configuration
|
||||
$ossClient->deleteBucketLifecycle($bucket);
|
||||
Common::println("bucket $bucket lifecycleConfig deleted");
|
||||
|
||||
|
||||
//***************************** For complete usage, see the following functions ***********************************************
|
||||
|
||||
putBucketLifecycle($ossClient, $bucket);
|
||||
getBucketLifecycle($ossClient, $bucket);
|
||||
deleteBucketLifecycle($ossClient, $bucket);
|
||||
getBucketLifecycle($ossClient, $bucket);
|
||||
|
||||
/**
|
||||
* Set bucket lifecycle configuration
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function putBucketLifecycle($ossClient, $bucket)
|
||||
{
|
||||
$lifecycleConfig = new LifecycleConfig();
|
||||
$actions = array();
|
||||
$actions[] = new LifecycleAction(OssClient::OSS_LIFECYCLE_EXPIRATION, OssClient::OSS_LIFECYCLE_TIMING_DAYS, 3);
|
||||
$lifecycleRule = new LifecycleRule("delete obsoleted files", "obsoleted/", "Enabled", $actions);
|
||||
$lifecycleConfig->addRule($lifecycleRule);
|
||||
$actions = array();
|
||||
$actions[] = new LifecycleAction(OssClient::OSS_LIFECYCLE_EXPIRATION, OssClient::OSS_LIFECYCLE_TIMING_DATE, '2022-10-12T00:00:00.000Z');
|
||||
$lifecycleRule = new LifecycleRule("delete temporary files", "temporary/", "Enabled", $actions);
|
||||
$lifecycleConfig->addRule($lifecycleRule);
|
||||
try {
|
||||
$ossClient->putBucketLifecycle($bucket, $lifecycleConfig);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bucket lifecycle configuration
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function getBucketLifecycle($ossClient, $bucket)
|
||||
{
|
||||
$lifecycleConfig = null;
|
||||
try {
|
||||
$lifecycleConfig = $ossClient->getBucketLifecycle($bucket);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
print($lifecycleConfig->serializeToXml() . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete bucket lifecycle configuration
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function deleteBucketLifecycle($ossClient, $bucket)
|
||||
{
|
||||
try {
|
||||
$ossClient->deleteBucketLifecycle($bucket);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
||||
|
||||
|
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Common.php';
|
||||
|
||||
use OSS\OssClient;
|
||||
use OSS\Core\OssException;
|
||||
|
||||
$bucket = Common::getBucketName();
|
||||
$ossClient = Common::getOssClient();
|
||||
if (is_null($ossClient)) exit(1);
|
||||
|
||||
//*******************************Simple Usage ***************************************************************
|
||||
|
||||
// Set bucket access logging rules. Access logs are stored under the same bucket with a 'access.log' prefix.
|
||||
$ossClient->putBucketLogging($bucket, $bucket, "access.log", array());
|
||||
Common::println("bucket $bucket lifecycleConfig created");
|
||||
|
||||
// Get bucket access logging rules
|
||||
$loggingConfig = $ossClient->getBucketLogging($bucket, array());
|
||||
Common::println("bucket $bucket lifecycleConfig fetched:" . $loggingConfig->serializeToXml());
|
||||
|
||||
// Delete bucket access logging rules
|
||||
$loggingConfig = $ossClient->getBucketLogging($bucket, array());
|
||||
Common::println("bucket $bucket lifecycleConfig deleted");
|
||||
|
||||
//******************************* For complete usage, see the following functions ****************************************************
|
||||
|
||||
putBucketLogging($ossClient, $bucket);
|
||||
getBucketLogging($ossClient, $bucket);
|
||||
deleteBucketLogging($ossClient, $bucket);
|
||||
getBucketLogging($ossClient, $bucket);
|
||||
|
||||
/**
|
||||
* Set bucket logging configuration
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function putBucketLogging($ossClient, $bucket)
|
||||
{
|
||||
$option = array();
|
||||
// Access logs are stored in the same bucket.
|
||||
$targetBucket = $bucket;
|
||||
$targetPrefix = "access.log";
|
||||
|
||||
try {
|
||||
$ossClient->putBucketLogging($bucket, $targetBucket, $targetPrefix, $option);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bucket logging configuration
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function getBucketLogging($ossClient, $bucket)
|
||||
{
|
||||
$loggingConfig = null;
|
||||
$options = array();
|
||||
try {
|
||||
$loggingConfig = $ossClient->getBucketLogging($bucket, $options);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
print($loggingConfig->serializeToXml() . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete bucket logging configuration
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function deleteBucketLogging($ossClient, $bucket)
|
||||
{
|
||||
try {
|
||||
$ossClient->deleteBucketLogging($bucket);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Common.php';
|
||||
|
||||
use OSS\OssClient;
|
||||
use OSS\Core\OssException;
|
||||
use \OSS\Model\RefererConfig;
|
||||
|
||||
$bucket = Common::getBucketName();
|
||||
$ossClient = Common::getOssClient();
|
||||
if (is_null($ossClient)) exit(1);
|
||||
|
||||
//******************************* Simple Usage ****************************************************************
|
||||
|
||||
// Set referer whitelist
|
||||
$refererConfig = new RefererConfig();
|
||||
$refererConfig->setAllowEmptyReferer(true);
|
||||
$refererConfig->addReferer("www.aliiyun.com");
|
||||
$refererConfig->addReferer("www.aliiyuncs.com");
|
||||
$ossClient->putBucketReferer($bucket, $refererConfig);
|
||||
Common::println("bucket $bucket refererConfig created:" . $refererConfig->serializeToXml());
|
||||
// Get referer whitelist
|
||||
$refererConfig = $ossClient->getBucketReferer($bucket);
|
||||
Common::println("bucket $bucket refererConfig fetched:" . $refererConfig->serializeToXml());
|
||||
|
||||
// Delete referrer whitelist
|
||||
$refererConfig = new RefererConfig();
|
||||
$ossClient->putBucketReferer($bucket, $refererConfig);
|
||||
Common::println("bucket $bucket refererConfig deleted");
|
||||
|
||||
|
||||
//******************************* For complete usage, see the following functions ****************************************************
|
||||
|
||||
putBucketReferer($ossClient, $bucket);
|
||||
getBucketReferer($ossClient, $bucket);
|
||||
deleteBucketReferer($ossClient, $bucket);
|
||||
getBucketReferer($ossClient, $bucket);
|
||||
|
||||
/**
|
||||
* Set bucket referer configuration
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function putBucketReferer($ossClient, $bucket)
|
||||
{
|
||||
$refererConfig = new RefererConfig();
|
||||
$refererConfig->setAllowEmptyReferer(true);
|
||||
$refererConfig->addReferer("www.aliiyun.com");
|
||||
$refererConfig->addReferer("www.aliiyuncs.com");
|
||||
try {
|
||||
$ossClient->putBucketReferer($bucket, $refererConfig);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bucket referer configuration
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function getBucketReferer($ossClient, $bucket)
|
||||
{
|
||||
$refererConfig = null;
|
||||
try {
|
||||
$refererConfig = $ossClient->getBucketReferer($bucket);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
print($refererConfig->serializeToXml() . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete bucket referer configuration
|
||||
* Referer whitelist cannot be directly deleted. So use a empty one to overwrite it.
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function deleteBucketReferer($ossClient, $bucket)
|
||||
{
|
||||
$refererConfig = new RefererConfig();
|
||||
try {
|
||||
$ossClient->putBucketReferer($bucket, $refererConfig);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Common.php';
|
||||
|
||||
use OSS\OssClient;
|
||||
use OSS\Core\OssException;
|
||||
use OSS\Model\WebsiteConfig;
|
||||
|
||||
$bucket = Common::getBucketName();
|
||||
$ossClient = Common::getOssClient();
|
||||
if (is_null($ossClient)) exit(1);
|
||||
|
||||
//******************************* Simple Usage ***************************************************************
|
||||
|
||||
// Set bucket static website configuration
|
||||
$websiteConfig = new WebsiteConfig("index.html", "error.html");
|
||||
$ossClient->putBucketWebsite($bucket, $websiteConfig);
|
||||
Common::println("bucket $bucket websiteConfig created:" . $websiteConfig->serializeToXml());
|
||||
|
||||
// Get bucket static website configuration
|
||||
$websiteConfig = $ossClient->getBucketWebsite($bucket);
|
||||
Common::println("bucket $bucket websiteConfig fetched:" . $websiteConfig->serializeToXml());
|
||||
|
||||
// Delete bucket static website configuration
|
||||
$ossClient->deleteBucketWebsite($bucket);
|
||||
Common::println("bucket $bucket websiteConfig deleted");
|
||||
|
||||
//******************************* For complete usage, see the following functions ****************************************************
|
||||
|
||||
putBucketWebsite($ossClient, $bucket);
|
||||
getBucketWebsite($ossClient, $bucket);
|
||||
deleteBucketWebsite($ossClient, $bucket);
|
||||
getBucketWebsite($ossClient, $bucket);
|
||||
|
||||
/**
|
||||
* Sets bucket static website configuration
|
||||
*
|
||||
* @param $ossClient OssClient
|
||||
* @param $bucket string bucket name
|
||||
* @return null
|
||||
*/
|
||||
function putBucketWebsite($ossClient, $bucket)
|
||||
{
|
||||
$websiteConfig = new WebsiteConfig("index.html", "error.html");
|
||||
try {
|
||||
$ossClient->putBucketWebsite($bucket, $websiteConfig);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bucket static website configuration
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function getBucketWebsite($ossClient, $bucket)
|
||||
{
|
||||
$websiteConfig = null;
|
||||
try {
|
||||
$websiteConfig = $ossClient->getBucketWebsite($bucket);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
print($websiteConfig->serializeToXml() . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete bucket static website configuration
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function deleteBucketWebsite($ossClient, $bucket)
|
||||
{
|
||||
try {
|
||||
$ossClient->deleteBucketWebsite($bucket);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Common.php';
|
||||
|
||||
use OSS\OssClient;
|
||||
|
||||
$bucket = Common::getBucketName();
|
||||
$ossClient = Common::getOssClient();
|
||||
if (is_null($ossClient)) exit(1);
|
||||
|
||||
//******************************* Simple Usage ***************************************************************
|
||||
|
||||
/** putObject Upload content to an OSS file using callback.
|
||||
* The callbackurl specifies the server url for the request callback.
|
||||
* The callbackbodytype can be application/json or application/x-www-form-urlencoded,the optional parameters,the default for the application/x - WWW - form - urlencoded
|
||||
* Users can choose not to set OSS_BACK_VAR
|
||||
*/
|
||||
$url =
|
||||
'{
|
||||
"callbackUrl":"callback.oss-demo.com:23450",
|
||||
"callbackHost":"oss-cn-hangzhou.aliyuncs.com",
|
||||
"callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}&my_var1=${x:var1}&my_var2=${x:var2}",
|
||||
"callbackBodyType":"application/x-www-form-urlencoded"
|
||||
|
||||
}';
|
||||
$var =
|
||||
'{
|
||||
"x:var1":"value1",
|
||||
"x:var2":"值2"
|
||||
}';
|
||||
$options = array(OssClient::OSS_CALLBACK => $url,
|
||||
OssClient::OSS_CALLBACK_VAR => $var
|
||||
);
|
||||
$result = $ossClient->putObject($bucket, "b.file", "random content", $options);
|
||||
Common::println($result['body']);
|
||||
Common::println($result['info']['http_code']);
|
||||
|
||||
/**
|
||||
* completeMultipartUpload Upload content to an OSS file using callback.
|
||||
* callbackurl specifies the server url for the request callback
|
||||
* The callbackbodytype can be application/json or application/x-www-form-urlencoded,the optional parameters,the default for the application/x - WWW - form - urlencoded
|
||||
* Users can choose not to set OSS_BACK_VAR.
|
||||
*/
|
||||
$object = "multipart-callback-test.txt";
|
||||
$copiedObject = "multipart-callback-test.txt.copied";
|
||||
$ossClient->putObject($bucket, $copiedObject, file_get_contents(__FILE__));
|
||||
|
||||
/**
|
||||
* step 1. Initialize a block upload event, that is, a multipart upload process to get an upload id
|
||||
*/
|
||||
$upload_id = $ossClient->initiateMultipartUpload($bucket, $object);
|
||||
|
||||
/**
|
||||
* step 2. uploadPartCopy
|
||||
*/
|
||||
$copyId = 1;
|
||||
$eTag = $ossClient->uploadPartCopy($bucket, $copiedObject, $bucket, $object, $copyId, $upload_id);
|
||||
$upload_parts[] = array(
|
||||
'PartNumber' => $copyId,
|
||||
'ETag' => $eTag,
|
||||
);
|
||||
$listPartsInfo = $ossClient->listParts($bucket, $object, $upload_id);
|
||||
|
||||
/**
|
||||
* step 3.
|
||||
*/
|
||||
$json =
|
||||
'{
|
||||
"callbackUrl":"callback.oss-demo.com:23450",
|
||||
"callbackHost":"oss-cn-hangzhou.aliyuncs.com",
|
||||
"callbackBody":"{\"mimeType\":${mimeType},\"size\":${size},\"x:var1\":${x:var1},\"x:var2\":${x:var2}}",
|
||||
"callbackBodyType":"application/json"
|
||||
}';
|
||||
$var =
|
||||
'{
|
||||
"x:var1":"value1",
|
||||
"x:var2":"值2"
|
||||
}';
|
||||
$options = array(OssClient::OSS_CALLBACK => $json,
|
||||
OssClient::OSS_CALLBACK_VAR => $var);
|
||||
|
||||
$result = $ossClient->completeMultipartUpload($bucket, $object, $upload_id, $upload_parts, $options);
|
||||
Common::println($result['body']);
|
||||
Common::println($result['info']['http_code']);
|
@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (is_file(__DIR__ . '/../autoload.php')) {
|
||||
require_once __DIR__ . '/../autoload.php';
|
||||
}
|
||||
if (is_file(__DIR__ . '/../vendor/autoload.php')) {
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
}
|
||||
require_once __DIR__ . '/Config.php';
|
||||
|
||||
use OSS\OssClient;
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class Common
|
||||
*
|
||||
* The Common class for 【Samples/*.php】 used to obtain OssClient instance and other common functions
|
||||
*/
|
||||
class Common
|
||||
{
|
||||
const endpoint = Config::OSS_ENDPOINT;
|
||||
const accessKeyId = Config::OSS_ACCESS_ID;
|
||||
const accessKeySecret = Config::OSS_ACCESS_KEY;
|
||||
const bucket = Config::OSS_TEST_BUCKET;
|
||||
|
||||
/**
|
||||
* Get an OSSClient instance according to config.
|
||||
*
|
||||
* @return OssClient An OssClient instance
|
||||
*/
|
||||
public static function getOssClient()
|
||||
{
|
||||
try {
|
||||
$ossClient = new OssClient(self::accessKeyId, self::accessKeySecret, self::endpoint, false);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . "creating OssClient instance: FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return null;
|
||||
}
|
||||
return $ossClient;
|
||||
}
|
||||
|
||||
public static function getBucketName()
|
||||
{
|
||||
return self::bucket;
|
||||
}
|
||||
|
||||
/**
|
||||
* A tool function which creates a bucket and exists the process if there are exceptions
|
||||
*/
|
||||
public static function createBucket()
|
||||
{
|
||||
$ossClient = self::getOssClient();
|
||||
if (is_null($ossClient)) exit(1);
|
||||
$bucket = self::getBucketName();
|
||||
$acl = OssClient::OSS_ACL_TYPE_PUBLIC_READ;
|
||||
try {
|
||||
$ossClient->createBucket($bucket, $acl);
|
||||
} catch (OssException $e) {
|
||||
|
||||
$message = $e->getMessage();
|
||||
if (\OSS\Core\OssUtil::startsWith($message, 'http status: 403')) {
|
||||
echo "Please Check your AccessKeyId and AccessKeySecret" . "\n";
|
||||
exit(0);
|
||||
} elseif (strpos($message, "BucketAlreadyExists") !== false) {
|
||||
echo "Bucket already exists. Please check whether the bucket belongs to you, or it was visited with correct endpoint. " . "\n";
|
||||
exit(0);
|
||||
}
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
||||
|
||||
public static function println($message)
|
||||
{
|
||||
if (!empty($message)) {
|
||||
echo strval($message) . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Common::createBucket();
|
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class Config
|
||||
*
|
||||
* Make configurations required by the sample.
|
||||
* Users can run RunAll.php which runs all the samples after configuring Endpoint, AccessId, and AccessKey.
|
||||
*/
|
||||
final class Config
|
||||
{
|
||||
const OSS_ACCESS_ID = 'update me';
|
||||
const OSS_ACCESS_KEY = 'update me';
|
||||
const OSS_ENDPOINT = 'update me';
|
||||
const OSS_TEST_BUCKET = 'update me';
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Common.php';
|
||||
|
||||
use OSS\OssClient;
|
||||
|
||||
$bucketName = Common::getBucketName();
|
||||
$object = "example.jpg";
|
||||
$ossClient = Common::getOssClient();
|
||||
$download_file = "download.jpg";
|
||||
if (is_null($ossClient)) exit(1);
|
||||
|
||||
//******************************* Simple Usage ***************************************************************
|
||||
|
||||
// Upload example.jpg to the specified bucket and rename it to $object.
|
||||
$ossClient->uploadFile($bucketName, $object, "example.jpg");
|
||||
|
||||
// Image resize
|
||||
$options = array(
|
||||
OssClient::OSS_FILE_DOWNLOAD => $download_file,
|
||||
OssClient::OSS_PROCESS => "image/resize,m_fixed,h_100,w_100", );
|
||||
$ossClient->getObject($bucketName, $object, $options);
|
||||
printImage("imageResize",$download_file);
|
||||
|
||||
// Image crop
|
||||
$options = array(
|
||||
OssClient::OSS_FILE_DOWNLOAD => $download_file,
|
||||
OssClient::OSS_PROCESS => "image/crop,w_100,h_100,x_100,y_100,r_1", );
|
||||
$ossClient->getObject($bucketName, $object, $options);
|
||||
printImage("iamgeCrop", $download_file);
|
||||
|
||||
// Image rotate
|
||||
$options = array(
|
||||
OssClient::OSS_FILE_DOWNLOAD => $download_file,
|
||||
OssClient::OSS_PROCESS => "image/rotate,90", );
|
||||
$ossClient->getObject($bucketName, $object, $options);
|
||||
printImage("imageRotate", $download_file);
|
||||
|
||||
// Image sharpen
|
||||
$options = array(
|
||||
OssClient::OSS_FILE_DOWNLOAD => $download_file,
|
||||
OssClient::OSS_PROCESS => "image/sharpen,100", );
|
||||
$ossClient->getObject($bucketName, $object, $options);
|
||||
printImage("imageSharpen", $download_file);
|
||||
|
||||
// Add watermark into a image
|
||||
$options = array(
|
||||
OssClient::OSS_FILE_DOWNLOAD => $download_file,
|
||||
OssClient::OSS_PROCESS => "image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ", );
|
||||
$ossClient->getObject($bucketName, $object, $options);
|
||||
printImage("imageWatermark", $download_file);
|
||||
|
||||
// Image format convertion
|
||||
$options = array(
|
||||
OssClient::OSS_FILE_DOWNLOAD => $download_file,
|
||||
OssClient::OSS_PROCESS => "image/format,png", );
|
||||
$ossClient->getObject($bucketName, $object, $options);
|
||||
printImage("imageFormat", $download_file);
|
||||
|
||||
// Get image information
|
||||
$options = array(
|
||||
OssClient::OSS_FILE_DOWNLOAD => $download_file,
|
||||
OssClient::OSS_PROCESS => "image/info", );
|
||||
$ossClient->getObject($bucketName, $object, $options);
|
||||
printImage("imageInfo", $download_file);
|
||||
|
||||
|
||||
/**
|
||||
* Generate a signed url which could be used in browser to access the object. The expiration time is 1 hour.
|
||||
*/
|
||||
$timeout = 3600;
|
||||
$options = array(
|
||||
OssClient::OSS_PROCESS => "image/resize,m_lfit,h_100,w_100",
|
||||
);
|
||||
$signedUrl = $ossClient->signUrl($bucketName, $object, $timeout, "GET", $options);
|
||||
Common::println("rtmp url: \n" . $signedUrl);
|
||||
|
||||
// Finally delete the $object uploaded.
|
||||
$ossClient->deleteObject($bucketName, $object);
|
||||
|
||||
function printImage($func, $imageFile)
|
||||
{
|
||||
$array = getimagesize($imageFile);
|
||||
Common::println("$func, image width: " . $array[0]);
|
||||
Common::println("$func, image height: " . $array[1]);
|
||||
Common::println("$func, image type: " . ($array[2] === 2 ? 'jpg' : 'png'));
|
||||
Common::println("$func, image size: " . ceil(filesize($imageFile)));
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Common.php';
|
||||
|
||||
use OSS\OssClient;
|
||||
use OSS\Model\LiveChannelConfig;
|
||||
|
||||
$bucket = Common::getBucketName();
|
||||
$ossClient = Common::getOssClient();
|
||||
if (is_null($ossClient)) exit(1);
|
||||
|
||||
//******************************* Simple Usage *******************************************************
|
||||
|
||||
/**
|
||||
* Create a Live Channel
|
||||
* The live channel's name is test_rtmp_live.
|
||||
* The play url file is named as test.m3u8, which includes 3 ts files.
|
||||
* The time period of each file is 5 seconds.(It is recommneded value only for demo purpose, the actual period depends on the key frame.)
|
||||
*
|
||||
*/
|
||||
$config = new LiveChannelConfig(array(
|
||||
'description' => 'live channel test',
|
||||
'type' => 'HLS',
|
||||
'fragDuration' => 10,
|
||||
'fragCount' => 5,
|
||||
'playListName' => 'hello.m3u8'
|
||||
));
|
||||
$info = $ossClient->putBucketLiveChannel($bucket, 'test_rtmp_live', $config);
|
||||
Common::println("bucket $bucket liveChannel created:\n" .
|
||||
"live channel name: ". $info->getName() . "\n" .
|
||||
"live channel description: ". $info->getDescription() . "\n" .
|
||||
"publishurls: ". $info->getPublishUrls()[0] . "\n" .
|
||||
"playurls: ". $info->getPlayUrls()[0] . "\n");
|
||||
|
||||
/**
|
||||
* You can use listBucketLiveChannels to list and manage all existing live channels.
|
||||
* Prefix can be used to filter listed live channels by prefix.
|
||||
* Max_keys indicates the maximum numbers of live channels that can be listed in an iterator at one time. Its value is 1000 in maximum and 100 by default.
|
||||
*/
|
||||
$list = $ossClient->listBucketLiveChannels($bucket);
|
||||
Common::println("bucket $bucket listLiveChannel:\n" .
|
||||
"list live channel prefix: ". $list->getPrefix() . "\n" .
|
||||
"list live channel marker: ". $list->getMarker() . "\n" .
|
||||
"list live channel maxkey: ". $list->getMaxKeys() . "\n" .
|
||||
"list live channel IsTruncated: ". $list->getIsTruncated() . "\n" .
|
||||
"list live channel getNextMarker: ". $list->getNextMarker() . "\n");
|
||||
|
||||
foreach($list->getChannelList() as $list)
|
||||
{
|
||||
Common::println("bucket $bucket listLiveChannel:\n" .
|
||||
"list live channel IsTruncated: ". $list->getName() . "\n" .
|
||||
"list live channel Description: ". $list->getDescription() . "\n" .
|
||||
"list live channel Status: ". $list->getStatus() . "\n" .
|
||||
"list live channel getNextMarker: ". $list->getLastModified() . "\n");
|
||||
}
|
||||
/**
|
||||
* Obtain the play_url (url used for rtmp stream pushing.
|
||||
* If the the bucket is not globally readable and writable,
|
||||
* the url must be signed as shown in the following.) and pulish_url (the url included in the m3u8 file generated in stream pushing) used to push streams.
|
||||
*/
|
||||
$play_url = $ossClient->signRtmpUrl($bucket, "test_rtmp_live", 3600, array('params' => array('playlistName' => 'playlist.m3u8')));
|
||||
Common::println("bucket $bucket rtmp url: \n" . $play_url);
|
||||
$play_url = $ossClient->signRtmpUrl($bucket, "test_rtmp_live", 3600);
|
||||
Common::println("bucket $bucket rtmp url: \n" . $play_url);
|
||||
|
||||
/**
|
||||
* If you want to disable a created live channel (disable the pushing streaming or do not allow stream pushing to an IP address), call putLiveChannelStatus to change the channel status to "Disabled".
|
||||
* If you want to enable a disabled live channel, call PutLiveChannelStatus to chanage the channel status to "Enabled".
|
||||
*/
|
||||
$resp = $ossClient->putLiveChannelStatus($bucket, "test_rtmp_live", "enabled");
|
||||
|
||||
/**
|
||||
* You can callLiveChannelInfo to get the information about a live channel.
|
||||
*/
|
||||
$info = $ossClient->getLiveChannelInfo($bucket, 'test_rtmp_live');
|
||||
Common::println("bucket $bucket LiveChannelInfo:\n" .
|
||||
"live channel info description: ". $info->getDescription() . "\n" .
|
||||
"live channel info status: ". $info->getStatus() . "\n" .
|
||||
"live channel info type: ". $info->getType() . "\n" .
|
||||
"live channel info fragDuration: ". $info->getFragDuration() . "\n" .
|
||||
"live channel info fragCount: ". $info->getFragCount() . "\n" .
|
||||
"live channel info playListName: ". $info->getPlayListName() . "\n");
|
||||
|
||||
/**
|
||||
* Gets the historical pushing streaming records by calling getLiveChannelHistory. Now the max records to return is 10.
|
||||
*/
|
||||
$history = $ossClient->getLiveChannelHistory($bucket, "test_rtmp_live");
|
||||
if (count($history->getLiveRecordList()) != 0)
|
||||
{
|
||||
foreach($history->getLiveRecordList() as $recordList)
|
||||
{
|
||||
Common::println("bucket $bucket liveChannelHistory:\n" .
|
||||
"live channel history startTime: ". $recordList->getStartTime() . "\n" .
|
||||
"live channel history endTime: ". $recordList->getEndTime() . "\n" .
|
||||
"live channel history remoteAddr: ". $recordList->getRemoteAddr() . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the live channel's status by calling getLiveChannelStatus.
|
||||
* If the live channel is receiving the pushing stream, all attributes in stat_result are valid.
|
||||
* If the live channel is idle or disabled, then the status is idle or Disabled and other attributes have no meaning.
|
||||
*/
|
||||
$status = $ossClient->getLiveChannelStatus($bucket, "test_rtmp_live");
|
||||
Common::println("bucket $bucket listLiveChannel:\n" .
|
||||
"live channel status status: ". $status->getStatus() . "\n" .
|
||||
"live channel status ConnectedTime: ". $status->getConnectedTime() . "\n" .
|
||||
"live channel status VideoWidth: ". $status->getVideoWidth() . "\n" .
|
||||
"live channel status VideoHeight: ". $status->getVideoHeight() . "\n" .
|
||||
"live channel status VideoFrameRate: ". $status->getVideoFrameRate() . "\n" .
|
||||
"live channel status VideoBandwidth: ". $status->getVideoBandwidth() . "\n" .
|
||||
"live channel status VideoCodec: ". $status->getVideoCodec() . "\n" .
|
||||
"live channel status AudioBandwidth: ". $status->getAudioBandwidth() . "\n" .
|
||||
"live channel status AudioSampleRate: ". $status->getAudioSampleRate() . "\n" .
|
||||
"live channel status AdioCodec: ". $status->getAudioCodec() . "\n");
|
||||
|
||||
/**
|
||||
* If you want to generate a play url from the ts files generated from pushing streaming, call postVodPlayList.
|
||||
* Specify the start time to 60 seconds before the current time and the end time to the current time, which means that a video of 60 seconds is generated.
|
||||
* The playlist file is specified to “vod_playlist.m3u8”, which means that a palylist file named vod_playlist.m3u8 is created after the interface is called.
|
||||
*/
|
||||
$current_time = time();
|
||||
$ossClient->postVodPlaylist($bucket,
|
||||
"test_rtmp_live", "vod_playlist.m3u8",
|
||||
array('StartTime' => $current_time - 60,
|
||||
'EndTime' => $current_time)
|
||||
);
|
||||
|
||||
/**
|
||||
* Call delete_live_channel to delete a live channel if it will no longer be in used.
|
||||
*/
|
||||
$ossClient->deleteBucketLiveChannel($bucket, "test_rtmp_live");
|
@ -1,182 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Common.php';
|
||||
|
||||
use OSS\OssClient;
|
||||
use OSS\Core\OssUtil;
|
||||
use OSS\Core\OssException;
|
||||
|
||||
$bucket = Common::getBucketName();
|
||||
$ossClient = Common::getOssClient();
|
||||
if (is_null($ossClient)) exit(1);
|
||||
|
||||
//******************************* Simple usage ***************************************************************
|
||||
|
||||
/**
|
||||
* See the putObjectByRawAPis usage in complete example to check out basic multipart upload APIs which can be used as resumable upload.
|
||||
*/
|
||||
|
||||
// Upload a file using the multipart upload interface, which determines to use simple upload or multipart upload based on the file size.
|
||||
$ossClient->multiuploadFile($bucket, "file.php", __FILE__, array());
|
||||
Common::println("local file " . __FILE__ . " is uploaded to the bucket $bucket, file.php");
|
||||
|
||||
|
||||
// Upload local directory's data into target dir
|
||||
$ossClient->uploadDir($bucket, "targetdir", __DIR__);
|
||||
Common::println("local dir " . __DIR__ . " is uploaded to the bucket $bucket, targetdir/");
|
||||
|
||||
|
||||
// List the incomplete multipart uploads
|
||||
$listMultipartUploadInfo = $ossClient->listMultipartUploads($bucket, array());
|
||||
|
||||
|
||||
//******************************* For complete usage, see the following functions ****************************************************
|
||||
|
||||
multiuploadFile($ossClient, $bucket);
|
||||
putObjectByRawApis($ossClient, $bucket);
|
||||
uploadDir($ossClient, $bucket);
|
||||
listMultipartUploads($ossClient, $bucket);
|
||||
|
||||
/**
|
||||
* Upload files using multipart upload
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
*/
|
||||
function multiuploadFile($ossClient, $bucket)
|
||||
{
|
||||
$object = "test/multipart-test.txt";
|
||||
$file = __FILE__;
|
||||
$options = array();
|
||||
|
||||
try {
|
||||
$ossClient->multiuploadFile($bucket, $object, $file, $options);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Use basic multipart upload for file upload.
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @throws OssException
|
||||
*/
|
||||
function putObjectByRawApis($ossClient, $bucket)
|
||||
{
|
||||
$object = "test/multipart-test.txt";
|
||||
/**
|
||||
* step 1. Initialize a block upload event, that is, a multipart upload process to get an upload id
|
||||
*/
|
||||
try {
|
||||
$uploadId = $ossClient->initiateMultipartUpload($bucket, $object);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": initiateMultipartUpload FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": initiateMultipartUpload OK" . "\n");
|
||||
/*
|
||||
* step 2. Upload parts
|
||||
*/
|
||||
$partSize = 10 * 1024 * 1024;
|
||||
$uploadFile = __FILE__;
|
||||
$uploadFileSize = filesize($uploadFile);
|
||||
$pieces = $ossClient->generateMultiuploadParts($uploadFileSize, $partSize);
|
||||
$responseUploadPart = array();
|
||||
$uploadPosition = 0;
|
||||
$isCheckMd5 = true;
|
||||
foreach ($pieces as $i => $piece) {
|
||||
$fromPos = $uploadPosition + (integer)$piece[$ossClient::OSS_SEEK_TO];
|
||||
$toPos = (integer)$piece[$ossClient::OSS_LENGTH] + $fromPos - 1;
|
||||
$upOptions = array(
|
||||
$ossClient::OSS_FILE_UPLOAD => $uploadFile,
|
||||
$ossClient::OSS_PART_NUM => ($i + 1),
|
||||
$ossClient::OSS_SEEK_TO => $fromPos,
|
||||
$ossClient::OSS_LENGTH => $toPos - $fromPos + 1,
|
||||
$ossClient::OSS_CHECK_MD5 => $isCheckMd5,
|
||||
);
|
||||
if ($isCheckMd5) {
|
||||
$contentMd5 = OssUtil::getMd5SumForFile($uploadFile, $fromPos, $toPos);
|
||||
$upOptions[$ossClient::OSS_CONTENT_MD5] = $contentMd5;
|
||||
}
|
||||
//2. Upload each part to OSS
|
||||
try {
|
||||
$responseUploadPart[] = $ossClient->uploadPart($bucket, $object, $uploadId, $upOptions);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": initiateMultipartUpload, uploadPart - part#{$i} FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
printf(__FUNCTION__ . ": initiateMultipartUpload, uploadPart - part#{$i} OK\n");
|
||||
}
|
||||
$uploadParts = array();
|
||||
foreach ($responseUploadPart as $i => $eTag) {
|
||||
$uploadParts[] = array(
|
||||
'PartNumber' => ($i + 1),
|
||||
'ETag' => $eTag,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* step 3. Complete the upload
|
||||
*/
|
||||
try {
|
||||
$ossClient->completeMultipartUpload($bucket, $object, $uploadId, $uploadParts);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": completeMultipartUpload FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
printf(__FUNCTION__ . ": completeMultipartUpload OK\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload by directories
|
||||
*
|
||||
* @param OssClient $ossClient OssClient
|
||||
* @param string $bucket bucket name
|
||||
*
|
||||
*/
|
||||
function uploadDir($ossClient, $bucket)
|
||||
{
|
||||
$localDirectory = ".";
|
||||
$prefix = "samples/codes";
|
||||
try {
|
||||
$ossClient->uploadDir($bucket, $prefix, $localDirectory);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
printf(__FUNCTION__ . ": completeMultipartUpload OK\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ongoing multipart uploads
|
||||
*
|
||||
* @param $ossClient OssClient
|
||||
* @param $bucket string
|
||||
*/
|
||||
function listMultipartUploads($ossClient, $bucket)
|
||||
{
|
||||
$options = array(
|
||||
'max-uploads' => 100,
|
||||
'key-marker' => '',
|
||||
'prefix' => '',
|
||||
'upload-id-marker' => ''
|
||||
);
|
||||
try {
|
||||
$listMultipartUploadInfo = $ossClient->listMultipartUploads($bucket, $options);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": listMultipartUploads FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
printf(__FUNCTION__ . ": listMultipartUploads OK\n");
|
||||
$listUploadInfo = $listMultipartUploadInfo->getUploads();
|
||||
var_dump($listUploadInfo);
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL | E_NOTICE);
|
||||
|
||||
require_once __DIR__ . '/Bucket.php';
|
||||
require_once __DIR__ . '/BucketCors.php';
|
||||
require_once __DIR__ . '/BucketLifecycle.php';
|
||||
require_once __DIR__ . '/BucketReferer.php';
|
||||
require_once __DIR__ . '/BucketLogging.php';
|
||||
require_once __DIR__ . '/BucketWebsite.php';
|
||||
require_once __DIR__ . '/Signature.php';
|
||||
require_once __DIR__ . '/Object1.php';
|
||||
require_once __DIR__ . '/MultipartUpload.php';
|
@ -1,142 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Common.php';
|
||||
|
||||
use OSS\Http\RequestCore;
|
||||
use OSS\Http\ResponseCore;
|
||||
use OSS\OssClient;
|
||||
use OSS\Core\OssException;
|
||||
|
||||
$bucket = Common::getBucketName();
|
||||
$ossClient = Common::getOssClient();
|
||||
if (is_null($ossClient)) exit(1);
|
||||
|
||||
//******************************* Simple Usage ***************************************************************
|
||||
|
||||
$ossClient->uploadFile($bucket, "a.file", __FILE__);
|
||||
|
||||
// Generate a signed url for getting an object. The URL can be used in browser directly to download the file.
|
||||
$signedUrl = $ossClient->signUrl($bucket, "a.file", 3600);
|
||||
Common::println($signedUrl);
|
||||
|
||||
// Generate the signed url for putting an object. User can use put method with this url to upload a file to "a.file".
|
||||
$signedUrl = $ossClient->signUrl($bucket, "a.file", "3600", "PUT");
|
||||
Common::println($signedUrl);
|
||||
|
||||
// Generate the signed url for putting an object from local file. The url can be used directly to upload the file to "a.file".
|
||||
$signedUrl = $ossClient->signUrl($bucket, "a.file", 3600, "PUT", array('Content-Type' => 'txt'));
|
||||
Common::println($signedUrl);
|
||||
|
||||
//******************************* For complete usage, see the following functions ****************************************************
|
||||
|
||||
getSignedUrlForPuttingObject($ossClient, $bucket);
|
||||
getSignedUrlForPuttingObjectFromFile($ossClient, $bucket);
|
||||
getSignedUrlForGettingObject($ossClient, $bucket);
|
||||
|
||||
/**
|
||||
* Generate the signed url for getObject() to control read accesses under private privilege
|
||||
*
|
||||
* @param $ossClient OssClient OssClient instance
|
||||
* @param $bucket string bucket name
|
||||
* @return null
|
||||
*/
|
||||
function getSignedUrlForGettingObject($ossClient, $bucket)
|
||||
{
|
||||
$object = "test/test-signature-test-upload-and-download.txt";
|
||||
$timeout = 3600;
|
||||
try {
|
||||
$signedUrl = $ossClient->signUrl($bucket, $object, $timeout);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n");
|
||||
/**
|
||||
* Use similar code to access the object by url, or use browser to access the object.
|
||||
*/
|
||||
$request = new RequestCore($signedUrl);
|
||||
$request->set_method('GET');
|
||||
$request->add_header('Content-Type', '');
|
||||
$request->send_request();
|
||||
$res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());
|
||||
if ($res->isOK()) {
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
} else {
|
||||
print(__FUNCTION__ . ": FAILED" . "\n");
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the signed url for PutObject to control write accesses under private privilege.
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @return null
|
||||
* @throws OssException
|
||||
*/
|
||||
function getSignedUrlForPuttingObject($ossClient, $bucket)
|
||||
{
|
||||
$object = "test/test-signature-test-upload-and-download.txt";
|
||||
$timeout = 3600;
|
||||
$options = NULL;
|
||||
try {
|
||||
$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT");
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n");
|
||||
$content = file_get_contents(__FILE__);
|
||||
|
||||
$request = new RequestCore($signedUrl);
|
||||
$request->set_method('PUT');
|
||||
$request->add_header('Content-Type', '');
|
||||
$request->add_header('Content-Length', strlen($content));
|
||||
$request->set_body($content);
|
||||
$request->send_request();
|
||||
$res = new ResponseCore($request->get_response_header(),
|
||||
$request->get_response_body(), $request->get_response_code());
|
||||
if ($res->isOK()) {
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
} else {
|
||||
print(__FUNCTION__ . ": FAILED" . "\n");
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the signed url for PutObject's signed url. User could use the signed url to upload file directly.
|
||||
*
|
||||
* @param OssClient $ossClient OssClient instance
|
||||
* @param string $bucket bucket name
|
||||
* @throws OssException
|
||||
*/
|
||||
function getSignedUrlForPuttingObjectFromFile($ossClient, $bucket)
|
||||
{
|
||||
$file = __FILE__;
|
||||
$object = "test/test-signature-test-upload-and-download.txt";
|
||||
$timeout = 3600;
|
||||
$options = array('Content-Type' => 'txt');
|
||||
try {
|
||||
$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options);
|
||||
} catch (OssException $e) {
|
||||
printf(__FUNCTION__ . ": FAILED\n");
|
||||
printf($e->getMessage() . "\n");
|
||||
return;
|
||||
}
|
||||
print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n");
|
||||
|
||||
$request = new RequestCore($signedUrl);
|
||||
$request->set_method('PUT');
|
||||
$request->add_header('Content-Type', 'txt');
|
||||
$request->set_read_file($file);
|
||||
$request->set_read_stream_size(filesize($file));
|
||||
$request->send_request();
|
||||
$res = new ResponseCore($request->get_response_header(),
|
||||
$request->get_response_body(), $request->get_response_code());
|
||||
if ($res->isOK()) {
|
||||
print(__FUNCTION__ . ": OK" . "\n");
|
||||
} else {
|
||||
print(__FUNCTION__ . ": FAILED" . "\n");
|
||||
};
|
||||
}
|
@ -1,263 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Core;
|
||||
|
||||
/**
|
||||
* Class MimeTypes
|
||||
*
|
||||
* The map of a file's extention name to its corresponding Content-Type value in the file upload request.
|
||||
* If the file extention name is not predefined in this class, getMimetype() returns null.
|
||||
*
|
||||
* @package OSS\Core
|
||||
*/
|
||||
class MimeTypes
|
||||
{
|
||||
/**
|
||||
* Get the content-type value of http header from the file's extension name.
|
||||
*
|
||||
* @param string $name Default file extension name.
|
||||
* @return string content-type
|
||||
*/
|
||||
public static function getMimetype($name)
|
||||
{
|
||||
$parts = explode('.', $name);
|
||||
if (count($parts) > 1) {
|
||||
$ext = strtolower(end($parts));
|
||||
if (isset(self::$mime_types[$ext])) {
|
||||
return self::$mime_types[$ext];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static $mime_types = array(
|
||||
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
|
||||
'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
|
||||
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
|
||||
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
|
||||
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
|
||||
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
|
||||
'apk' => 'application/vnd.android.package-archive',
|
||||
'hqx' => 'application/mac-binhex40',
|
||||
'cpt' => 'application/mac-compactpro',
|
||||
'doc' => 'application/msword',
|
||||
'ogg' => 'audio/ogg',
|
||||
'pdf' => 'application/pdf',
|
||||
'rtf' => 'text/rtf',
|
||||
'mif' => 'application/vnd.mif',
|
||||
'xls' => 'application/vnd.ms-excel',
|
||||
'ppt' => 'application/vnd.ms-powerpoint',
|
||||
'odc' => 'application/vnd.oasis.opendocument.chart',
|
||||
'odb' => 'application/vnd.oasis.opendocument.database',
|
||||
'odf' => 'application/vnd.oasis.opendocument.formula',
|
||||
'odg' => 'application/vnd.oasis.opendocument.graphics',
|
||||
'otg' => 'application/vnd.oasis.opendocument.graphics-template',
|
||||
'odi' => 'application/vnd.oasis.opendocument.image',
|
||||
'odp' => 'application/vnd.oasis.opendocument.presentation',
|
||||
'otp' => 'application/vnd.oasis.opendocument.presentation-template',
|
||||
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
||||
'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
|
||||
'odt' => 'application/vnd.oasis.opendocument.text',
|
||||
'odm' => 'application/vnd.oasis.opendocument.text-master',
|
||||
'ott' => 'application/vnd.oasis.opendocument.text-template',
|
||||
'oth' => 'application/vnd.oasis.opendocument.text-web',
|
||||
'sxw' => 'application/vnd.sun.xml.writer',
|
||||
'stw' => 'application/vnd.sun.xml.writer.template',
|
||||
'sxc' => 'application/vnd.sun.xml.calc',
|
||||
'stc' => 'application/vnd.sun.xml.calc.template',
|
||||
'sxd' => 'application/vnd.sun.xml.draw',
|
||||
'std' => 'application/vnd.sun.xml.draw.template',
|
||||
'sxi' => 'application/vnd.sun.xml.impress',
|
||||
'sti' => 'application/vnd.sun.xml.impress.template',
|
||||
'sxg' => 'application/vnd.sun.xml.writer.global',
|
||||
'sxm' => 'application/vnd.sun.xml.math',
|
||||
'sis' => 'application/vnd.symbian.install',
|
||||
'wbxml' => 'application/vnd.wap.wbxml',
|
||||
'wmlc' => 'application/vnd.wap.wmlc',
|
||||
'wmlsc' => 'application/vnd.wap.wmlscriptc',
|
||||
'bcpio' => 'application/x-bcpio',
|
||||
'torrent' => 'application/x-bittorrent',
|
||||
'bz2' => 'application/x-bzip2',
|
||||
'vcd' => 'application/x-cdlink',
|
||||
'pgn' => 'application/x-chess-pgn',
|
||||
'cpio' => 'application/x-cpio',
|
||||
'csh' => 'application/x-csh',
|
||||
'dvi' => 'application/x-dvi',
|
||||
'spl' => 'application/x-futuresplash',
|
||||
'gtar' => 'application/x-gtar',
|
||||
'hdf' => 'application/x-hdf',
|
||||
'jar' => 'application/java-archive',
|
||||
'jnlp' => 'application/x-java-jnlp-file',
|
||||
'js' => 'application/javascript',
|
||||
'json' => 'application/json',
|
||||
'ksp' => 'application/x-kspread',
|
||||
'chrt' => 'application/x-kchart',
|
||||
'kil' => 'application/x-killustrator',
|
||||
'latex' => 'application/x-latex',
|
||||
'rpm' => 'application/x-rpm',
|
||||
'sh' => 'application/x-sh',
|
||||
'shar' => 'application/x-shar',
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'sit' => 'application/x-stuffit',
|
||||
'sv4cpio' => 'application/x-sv4cpio',
|
||||
'sv4crc' => 'application/x-sv4crc',
|
||||
'tar' => 'application/x-tar',
|
||||
'tcl' => 'application/x-tcl',
|
||||
'tex' => 'application/x-tex',
|
||||
'man' => 'application/x-troff-man',
|
||||
'me' => 'application/x-troff-me',
|
||||
'ms' => 'application/x-troff-ms',
|
||||
'ustar' => 'application/x-ustar',
|
||||
'src' => 'application/x-wais-source',
|
||||
'zip' => 'application/zip',
|
||||
'm3u' => 'audio/x-mpegurl',
|
||||
'ra' => 'audio/x-pn-realaudio',
|
||||
'wav' => 'audio/x-wav',
|
||||
'wma' => 'audio/x-ms-wma',
|
||||
'wax' => 'audio/x-ms-wax',
|
||||
'pdb' => 'chemical/x-pdb',
|
||||
'xyz' => 'chemical/x-xyz',
|
||||
'bmp' => 'image/bmp',
|
||||
'gif' => 'image/gif',
|
||||
'ief' => 'image/ief',
|
||||
'png' => 'image/png',
|
||||
'wbmp' => 'image/vnd.wap.wbmp',
|
||||
'ras' => 'image/x-cmu-raster',
|
||||
'pnm' => 'image/x-portable-anymap',
|
||||
'pbm' => 'image/x-portable-bitmap',
|
||||
'pgm' => 'image/x-portable-graymap',
|
||||
'ppm' => 'image/x-portable-pixmap',
|
||||
'rgb' => 'image/x-rgb',
|
||||
'xbm' => 'image/x-xbitmap',
|
||||
'xpm' => 'image/x-xpixmap',
|
||||
'xwd' => 'image/x-xwindowdump',
|
||||
'css' => 'text/css',
|
||||
'rtx' => 'text/richtext',
|
||||
'tsv' => 'text/tab-separated-values',
|
||||
'jad' => 'text/vnd.sun.j2me.app-descriptor',
|
||||
'wml' => 'text/vnd.wap.wml',
|
||||
'wmls' => 'text/vnd.wap.wmlscript',
|
||||
'etx' => 'text/x-setext',
|
||||
'mxu' => 'video/vnd.mpegurl',
|
||||
'flv' => 'video/x-flv',
|
||||
'wm' => 'video/x-ms-wm',
|
||||
'wmv' => 'video/x-ms-wmv',
|
||||
'wmx' => 'video/x-ms-wmx',
|
||||
'wvx' => 'video/x-ms-wvx',
|
||||
'avi' => 'video/x-msvideo',
|
||||
'movie' => 'video/x-sgi-movie',
|
||||
'ice' => 'x-conference/x-cooltalk',
|
||||
'3gp' => 'video/3gpp',
|
||||
'ai' => 'application/postscript',
|
||||
'aif' => 'audio/x-aiff',
|
||||
'aifc' => 'audio/x-aiff',
|
||||
'aiff' => 'audio/x-aiff',
|
||||
'asc' => 'text/plain',
|
||||
'atom' => 'application/atom+xml',
|
||||
'au' => 'audio/basic',
|
||||
'bin' => 'application/octet-stream',
|
||||
'cdf' => 'application/x-netcdf',
|
||||
'cgm' => 'image/cgm',
|
||||
'class' => 'application/octet-stream',
|
||||
'dcr' => 'application/x-director',
|
||||
'dif' => 'video/x-dv',
|
||||
'dir' => 'application/x-director',
|
||||
'djv' => 'image/vnd.djvu',
|
||||
'djvu' => 'image/vnd.djvu',
|
||||
'dll' => 'application/octet-stream',
|
||||
'dmg' => 'application/octet-stream',
|
||||
'dms' => 'application/octet-stream',
|
||||
'dtd' => 'application/xml-dtd',
|
||||
'dv' => 'video/x-dv',
|
||||
'dxr' => 'application/x-director',
|
||||
'eps' => 'application/postscript',
|
||||
'exe' => 'application/octet-stream',
|
||||
'ez' => 'application/andrew-inset',
|
||||
'gram' => 'application/srgs',
|
||||
'grxml' => 'application/srgs+xml',
|
||||
'gz' => 'application/x-gzip',
|
||||
'htm' => 'text/html',
|
||||
'html' => 'text/html',
|
||||
'ico' => 'image/x-icon',
|
||||
'ics' => 'text/calendar',
|
||||
'ifb' => 'text/calendar',
|
||||
'iges' => 'model/iges',
|
||||
'igs' => 'model/iges',
|
||||
'jp2' => 'image/jp2',
|
||||
'jpe' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'jpg' => 'image/jpeg',
|
||||
'kar' => 'audio/midi',
|
||||
'lha' => 'application/octet-stream',
|
||||
'lzh' => 'application/octet-stream',
|
||||
'm4a' => 'audio/mp4a-latm',
|
||||
'm4p' => 'audio/mp4a-latm',
|
||||
'm4u' => 'video/vnd.mpegurl',
|
||||
'm4v' => 'video/x-m4v',
|
||||
'mac' => 'image/x-macpaint',
|
||||
'mathml' => 'application/mathml+xml',
|
||||
'mesh' => 'model/mesh',
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'mov' => 'video/quicktime',
|
||||
'mp2' => 'audio/mpeg',
|
||||
'mp3' => 'audio/mpeg',
|
||||
'mp4' => 'video/mp4',
|
||||
'mpe' => 'video/mpeg',
|
||||
'mpeg' => 'video/mpeg',
|
||||
'mpg' => 'video/mpeg',
|
||||
'mpga' => 'audio/mpeg',
|
||||
'msh' => 'model/mesh',
|
||||
'nc' => 'application/x-netcdf',
|
||||
'oda' => 'application/oda',
|
||||
'ogv' => 'video/ogv',
|
||||
'pct' => 'image/pict',
|
||||
'pic' => 'image/pict',
|
||||
'pict' => 'image/pict',
|
||||
'pnt' => 'image/x-macpaint',
|
||||
'pntg' => 'image/x-macpaint',
|
||||
'ps' => 'application/postscript',
|
||||
'qt' => 'video/quicktime',
|
||||
'qti' => 'image/x-quicktime',
|
||||
'qtif' => 'image/x-quicktime',
|
||||
'ram' => 'audio/x-pn-realaudio',
|
||||
'rdf' => 'application/rdf+xml',
|
||||
'rm' => 'application/vnd.rn-realmedia',
|
||||
'roff' => 'application/x-troff',
|
||||
'sgm' => 'text/sgml',
|
||||
'sgml' => 'text/sgml',
|
||||
'silo' => 'model/mesh',
|
||||
'skd' => 'application/x-koan',
|
||||
'skm' => 'application/x-koan',
|
||||
'skp' => 'application/x-koan',
|
||||
'skt' => 'application/x-koan',
|
||||
'smi' => 'application/smil',
|
||||
'smil' => 'application/smil',
|
||||
'snd' => 'audio/basic',
|
||||
'so' => 'application/octet-stream',
|
||||
'svg' => 'image/svg+xml',
|
||||
't' => 'application/x-troff',
|
||||
'texi' => 'application/x-texinfo',
|
||||
'texinfo' => 'application/x-texinfo',
|
||||
'tif' => 'image/tiff',
|
||||
'tiff' => 'image/tiff',
|
||||
'tr' => 'application/x-troff',
|
||||
'txt' => 'text/plain',
|
||||
'vrml' => 'model/vrml',
|
||||
'vxml' => 'application/voicexml+xml',
|
||||
'webm' => 'video/webm',
|
||||
'webp' => 'image/webp',
|
||||
'wrl' => 'model/vrml',
|
||||
'xht' => 'application/xhtml+xml',
|
||||
'xhtml' => 'application/xhtml+xml',
|
||||
'xml' => 'application/xml',
|
||||
'xsl' => 'application/xml',
|
||||
'xslt' => 'application/xslt+xml',
|
||||
'xul' => 'application/vnd.mozilla.xul+xml',
|
||||
);
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Core;
|
||||
|
||||
/**
|
||||
* Class OssException
|
||||
*
|
||||
* This is the class that OSSClient is expected to thrown, which the caller needs to handle properly.
|
||||
* It has the OSS specific errors which is useful for troubleshooting.
|
||||
*
|
||||
* @package OSS\Core
|
||||
*/
|
||||
class OssException extends \Exception
|
||||
{
|
||||
private $details = array();
|
||||
|
||||
function __construct($details)
|
||||
{
|
||||
if (is_array($details)) {
|
||||
$message = $details['code'] . ': ' . $details['message']
|
||||
. ' RequestId: ' . $details['request-id'];
|
||||
parent::__construct($message);
|
||||
$this->details = $details;
|
||||
} else {
|
||||
$message = $details;
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function getHTTPStatus()
|
||||
{
|
||||
return isset($this->details['status']) ? $this->details['status'] : '';
|
||||
}
|
||||
|
||||
public function getRequestId()
|
||||
{
|
||||
return isset($this->details['request-id']) ? $this->details['request-id'] : '';
|
||||
}
|
||||
|
||||
public function getErrorCode()
|
||||
{
|
||||
return isset($this->details['code']) ? $this->details['code'] : '';
|
||||
}
|
||||
|
||||
public function getErrorMessage()
|
||||
{
|
||||
return isset($this->details['message']) ? $this->details['message'] : '';
|
||||
}
|
||||
|
||||
public function getDetails()
|
||||
{
|
||||
return isset($this->details['body']) ? $this->details['body'] : '';
|
||||
}
|
||||
}
|
@ -1,530 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Core;
|
||||
|
||||
/**
|
||||
* Class OssUtil
|
||||
*
|
||||
* Oss Util class for OssClient. The caller could use it for formating the result from OssClient.
|
||||
*
|
||||
* @package OSS
|
||||
*/
|
||||
class OssUtil
|
||||
{
|
||||
const OSS_CONTENT = 'content';
|
||||
const OSS_LENGTH = 'length';
|
||||
const OSS_HEADERS = 'headers';
|
||||
const OSS_MAX_OBJECT_GROUP_VALUE = 1000;
|
||||
const OSS_MAX_PART_SIZE = 5368709120; // 5GB
|
||||
const OSS_MID_PART_SIZE = 10485760; // 10MB
|
||||
const OSS_MIN_PART_SIZE = 102400; // 100KB
|
||||
|
||||
/**
|
||||
* Generate query params
|
||||
*
|
||||
* @param array $options: a key-value pair array.
|
||||
* @return string: the key-value list in the format such as key1=value1&key2=value2
|
||||
*/
|
||||
public static function toQueryString($options = array())
|
||||
{
|
||||
$temp = array();
|
||||
uksort($options, 'strnatcasecmp');
|
||||
foreach ($options as $key => $value) {
|
||||
if (is_string($key) && !is_array($value)) {
|
||||
$temp[] = rawurlencode($key) . '=' . rawurlencode($value);
|
||||
}
|
||||
}
|
||||
return implode('&', $temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Html encoding '<', '>', '&', '\', '"' in subject parameter.
|
||||
*
|
||||
* @param string $subject
|
||||
* @return string
|
||||
*/
|
||||
public static function sReplace($subject)
|
||||
{
|
||||
$search = array('<', '>', '&', '\'', '"');
|
||||
$replace = array('<', '>', '&', ''', '"');
|
||||
return str_replace($search, $replace, $subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the string includes any chinese character
|
||||
*
|
||||
* @param $str
|
||||
* @return int
|
||||
*/
|
||||
public static function chkChinese($str)
|
||||
{
|
||||
return preg_match('/[\x80-\xff]./', $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the string is encoded by GB2312.
|
||||
*
|
||||
* @param string $str
|
||||
* @return boolean false UTF-8 encoding TRUE GB2312 encoding
|
||||
*/
|
||||
public static function isGb2312($str)
|
||||
{
|
||||
for ($i = 0; $i < strlen($str); $i++) {
|
||||
$v = ord($str[$i]);
|
||||
if ($v > 127) {
|
||||
if (($v >= 228) && ($v <= 233)) {
|
||||
if (($i + 2) >= (strlen($str) - 1)) return true; // not enough characters
|
||||
$v1 = ord($str[$i + 1]);
|
||||
$v2 = ord($str[$i + 2]);
|
||||
if (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the string is encoded by GBK
|
||||
*
|
||||
* @param string $str
|
||||
* @param boolean $gbk
|
||||
* @return boolean
|
||||
*/
|
||||
public static function checkChar($str, $gbk = true)
|
||||
{
|
||||
for ($i = 0; $i < strlen($str); $i++) {
|
||||
$v = ord($str[$i]);
|
||||
if ($v > 127) {
|
||||
if (($v >= 228) && ($v <= 233)) {
|
||||
if (($i + 2) >= (strlen($str) - 1)) return $gbk ? true : FALSE; // not enough characters
|
||||
$v1 = ord($str[$i + 1]);
|
||||
$v2 = ord($str[$i + 2]);
|
||||
if ($gbk) {
|
||||
return (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) ? FALSE : TRUE;//GBK
|
||||
} else {
|
||||
return (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) ? TRUE : FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $gbk ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the bucket name is valid
|
||||
* bucket naming rules
|
||||
* 1. Can only include lowercase letters, numbers, or dashes
|
||||
* 2. Must start and end with lowercase letters or numbers
|
||||
* 3. Must be within a length from 3 to 63 bytes.
|
||||
*
|
||||
* @param string $bucket Bucket name
|
||||
* @return boolean
|
||||
*/
|
||||
public static function validateBucket($bucket)
|
||||
{
|
||||
$pattern = '/^[a-z0-9][a-z0-9-]{2,62}$/';
|
||||
if (!preg_match($pattern, $bucket)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if object name is valid
|
||||
* object naming rules:
|
||||
* 1. Must be within a length from 1 to 1023 bytes
|
||||
* 2. Cannot start with '/' or '\\'.
|
||||
* 3. Must be encoded in UTF-8.
|
||||
*
|
||||
* @param string $object Object名称
|
||||
* @return boolean
|
||||
*/
|
||||
public static function validateObject($object)
|
||||
{
|
||||
$pattern = '/^.{1,1023}$/';
|
||||
if (!preg_match($pattern, $object) ||
|
||||
self::startsWith($object, '/') || self::startsWith($object, '\\')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if $str starts with $findMe
|
||||
*
|
||||
* @param string $str
|
||||
* @param string $findMe
|
||||
* @return bool
|
||||
*/
|
||||
public static function startsWith($str, $findMe)
|
||||
{
|
||||
if (strpos($str, $findMe) === 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate the xml message of createBucketXmlBody.
|
||||
*
|
||||
* @param string $storageClass
|
||||
* @return string
|
||||
*/
|
||||
public static function createBucketXmlBody($storageClass)
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><CreateBucketConfiguration></CreateBucketConfiguration>');
|
||||
$xml->addChild('StorageClass', $storageClass);
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* validate $options
|
||||
*
|
||||
* @param array $options
|
||||
* @throws OssException
|
||||
* @return boolean
|
||||
*/
|
||||
public static function validateOptions($options)
|
||||
{
|
||||
//$options
|
||||
if ($options != NULL && !is_array($options)) {
|
||||
throw new OssException ($options . ':' . 'option must be array');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether the Content is valid.
|
||||
*
|
||||
* @param $content string
|
||||
* @throws OssException
|
||||
*/
|
||||
public static function validateContent($content)
|
||||
{
|
||||
if (empty($content)) {
|
||||
throw new OssException("http body content is invalid");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if BUCKET/OBJECT/OBJECT GROUP is empty.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $errMsg
|
||||
* @throws OssException
|
||||
* @return void
|
||||
*/
|
||||
public static function throwOssExceptionWithMessageIfEmpty($name, $errMsg)
|
||||
{
|
||||
if (empty($name)) {
|
||||
if (is_string($name) && $name == '0')
|
||||
return;
|
||||
throw new OssException($errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a method for test only. DO NOT USE.
|
||||
*
|
||||
* @param $filename
|
||||
* @param $size
|
||||
*/
|
||||
public static function generateFile($filename, $size)
|
||||
{
|
||||
if (file_exists($filename) && $size == filesize($filename)) {
|
||||
echo $filename . " already exists, no need to create again. ";
|
||||
return;
|
||||
}
|
||||
$part_size = 1 * 1024 * 1024;
|
||||
$fp = fopen($filename, "w");
|
||||
$characters = <<<BBB
|
||||
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
BBB;
|
||||
|
||||
$charactersLength = strlen($characters);
|
||||
if ($fp) {
|
||||
while ($size > 0) {
|
||||
if ($size < $part_size) {
|
||||
$write_size = $size;
|
||||
} else {
|
||||
$write_size = $part_size;
|
||||
}
|
||||
$size -= $write_size;
|
||||
$a = $characters[rand(0, $charactersLength - 1)];
|
||||
$content = str_repeat($a, $write_size);
|
||||
$flag = fwrite($fp, $content);
|
||||
if (!$flag) {
|
||||
echo "write to " . $filename . " failed. <br>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "open " . $filename . " failed. <br>";
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get MD5 of the file.
|
||||
*
|
||||
* @param $filename
|
||||
* @param $from_pos
|
||||
* @param $to_pos
|
||||
* @return string
|
||||
*/
|
||||
public static function getMd5SumForFile($filename, $from_pos, $to_pos)
|
||||
{
|
||||
$content_md5 = "";
|
||||
if (($to_pos - $from_pos) > self::OSS_MAX_PART_SIZE) {
|
||||
return $content_md5;
|
||||
}
|
||||
$filesize = filesize($filename);
|
||||
if ($from_pos >= $filesize || $to_pos >= $filesize || $from_pos < 0 || $to_pos < 0) {
|
||||
return $content_md5;
|
||||
}
|
||||
|
||||
$total_length = $to_pos - $from_pos + 1;
|
||||
$buffer = 8192;
|
||||
$left_length = $total_length;
|
||||
if (!file_exists($filename)) {
|
||||
return $content_md5;
|
||||
}
|
||||
|
||||
if (false === $fh = fopen($filename, 'rb')) {
|
||||
return $content_md5;
|
||||
}
|
||||
|
||||
fseek($fh, $from_pos);
|
||||
$data = '';
|
||||
while (!feof($fh)) {
|
||||
if ($left_length >= $buffer) {
|
||||
$read_length = $buffer;
|
||||
} else {
|
||||
$read_length = $left_length;
|
||||
}
|
||||
if ($read_length <= 0) {
|
||||
break;
|
||||
} else {
|
||||
$data .= fread($fh, $read_length);
|
||||
$left_length = $left_length - $read_length;
|
||||
}
|
||||
}
|
||||
fclose($fh);
|
||||
$content_md5 = base64_encode(md5($data, true));
|
||||
return $content_md5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the OS is Windows. The default encoding in Windows is GBK.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isWin()
|
||||
{
|
||||
return strtoupper(substr(PHP_OS, 0, 3)) == "WIN";
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the file path from GBK to UTF-8.
|
||||
* The default encoding in Windows is GBK.
|
||||
* And if the file path is in Chinese, the file would not be found without the transcoding to UTF-8.
|
||||
*
|
||||
* @param $file_path
|
||||
* @return string
|
||||
*/
|
||||
public static function encodePath($file_path)
|
||||
{
|
||||
if (self::chkChinese($file_path) && self::isWin()) {
|
||||
$file_path = iconv('utf-8', 'gbk', $file_path);
|
||||
}
|
||||
return $file_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the endpoint is in the IPv4 format, such as xxx.xxx.xxx.xxx:port or xxx.xxx.xxx.xxx.
|
||||
*
|
||||
* @param string $endpoint The endpoint to check.
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isIPFormat($endpoint)
|
||||
{
|
||||
$ip_array = explode(":", $endpoint);
|
||||
$hostname = $ip_array[0];
|
||||
$ret = filter_var($hostname, FILTER_VALIDATE_IP);
|
||||
if (!$ret) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the host:port from endpoint.
|
||||
*
|
||||
* @param string $endpoint the endpoint.
|
||||
* @return boolean
|
||||
*/
|
||||
public static function getHostPortFromEndpoint($endpoint)
|
||||
{
|
||||
$str = $endpoint;
|
||||
$pos = strpos($str, "://");
|
||||
if ($pos !== false) {
|
||||
$str = substr($str, $pos+3);
|
||||
}
|
||||
|
||||
$pos = strpos($str, '#');
|
||||
if ($pos !== false) {
|
||||
$str = substr($str, 0, $pos);
|
||||
}
|
||||
|
||||
$pos = strpos($str, '?');
|
||||
if ($pos !== false) {
|
||||
$str = substr($str, 0, $pos);
|
||||
}
|
||||
|
||||
$pos = strpos($str, '/');
|
||||
if ($pos !== false) {
|
||||
$str = substr($str, 0, $pos);
|
||||
}
|
||||
|
||||
$pos = strpos($str, '@');
|
||||
if ($pos !== false) {
|
||||
$str = substr($str, $pos+1);
|
||||
}
|
||||
|
||||
if (!preg_match('/^[\w.-]+(:[0-9]+)?$/', $str)) {
|
||||
throw new OssException("endpoint is invalid:" . $endpoint);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the xml message of DeleteMultiObjects.
|
||||
*
|
||||
* @param string[] $objects
|
||||
* @param bool $quiet
|
||||
* @return string
|
||||
*/
|
||||
public static function createDeleteObjectsXmlBody($objects, $quiet)
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><Delete></Delete>');
|
||||
$xml->addChild('Quiet', $quiet);
|
||||
foreach ($objects as $object) {
|
||||
$sub_object = $xml->addChild('Object');
|
||||
$object = OssUtil::sReplace($object);
|
||||
$sub_object->addChild('Key', $object);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the xml message of DeleteMultiObjects.
|
||||
*
|
||||
* @param DeleteObjectInfo[] $objects
|
||||
* @param bool $quiet
|
||||
* @return string
|
||||
*/
|
||||
public static function createDeleteObjectVersionsXmlBody($objects, $quiet)
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><Delete></Delete>');
|
||||
$xml->addChild('Quiet', $quiet);
|
||||
foreach ($objects as $object) {
|
||||
$sub_object = $xml->addChild('Object');
|
||||
$key = OssUtil::sReplace($object->getKey());
|
||||
$sub_object->addChild('Key', $key);
|
||||
$versionId = $object->getVersionId();
|
||||
if (!empty($versionId)) {
|
||||
$sub_object->addChild('VersionId', $object->getVersionId());
|
||||
}
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the xml message of CompleteMultipartUpload.
|
||||
*
|
||||
* @param array[] $listParts
|
||||
* @return string
|
||||
*/
|
||||
public static function createCompleteMultipartUploadXmlBody($listParts)
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><CompleteMultipartUpload></CompleteMultipartUpload>');
|
||||
foreach ($listParts as $node) {
|
||||
$part = $xml->addChild('Part');
|
||||
$part->addChild('PartNumber', $node['PartNumber']);
|
||||
$part->addChild('ETag', $node['ETag']);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the directory, return a associative array in which the MD5 is the named key and the <path,filanme> is the value.
|
||||
*
|
||||
* @param string $dir
|
||||
* @param string $exclude
|
||||
* @param bool $recursive
|
||||
* @return string[]
|
||||
*/
|
||||
public static function readDir($dir, $exclude = ".|..|.svn|.git", $recursive = false)
|
||||
{
|
||||
$file_list_array = array();
|
||||
$base_path = $dir;
|
||||
$exclude_array = explode("|", $exclude);
|
||||
$exclude_array = array_unique(array_merge($exclude_array, array('.', '..')));
|
||||
|
||||
if ($recursive) {
|
||||
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)) as $new_file) {
|
||||
if ($new_file->isDir()) continue;
|
||||
$object = str_replace($base_path, '', $new_file);
|
||||
if (!in_array(strtolower($object), $exclude_array)) {
|
||||
$object = ltrim($object, '/');
|
||||
if (is_file($new_file)) {
|
||||
$key = md5($new_file . $object, false);
|
||||
$file_list_array[$key] = array('path' => $new_file, 'file' => $object,);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($handle = opendir($dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (!in_array(strtolower($file), $exclude_array)) {
|
||||
$new_file = $dir . '/' . $file;
|
||||
$object = $file;
|
||||
$object = ltrim($object, '/');
|
||||
if (is_file($new_file)) {
|
||||
$key = md5($new_file . $object, false);
|
||||
$file_list_array[$key] = array('path' => $new_file, 'file' => $object,);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
return $file_list_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode key based on the encoding type
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $encoding
|
||||
* @return string
|
||||
*/
|
||||
public static function decodeKey($key, $encoding)
|
||||
{
|
||||
if ($encoding == "") {
|
||||
return $key;
|
||||
}
|
||||
|
||||
if ($encoding == "url") {
|
||||
return rawurldecode($key);
|
||||
} else {
|
||||
throw new OssException("Unrecognized encoding type: " . $encoding);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
Copyright (c) 2006-2010 Ryan Parman, Foleeo Inc., and contributors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are
|
||||
permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
of conditions and the following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
* Neither the name of Ryan Parman, Foleeo Inc. nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
|
||||
AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
@ -1,898 +0,0 @@
|
||||
<?php
|
||||
namespace OSS\Http;
|
||||
|
||||
|
||||
/**
|
||||
* Handle all HTTP requests using cURL and manages the responses.
|
||||
*
|
||||
* @version 2011.06.07
|
||||
* @copyright 2006-2011 Ryan Parman
|
||||
* @copyright 2006-2010 Foleeo Inc.
|
||||
* @copyright 2010-2011 Amazon.com, Inc. or its affiliates.
|
||||
* @copyright 2008-2011 Contributors
|
||||
* @license http://opensource.org/licenses/bsd-license.php Simplified BSD License
|
||||
*/
|
||||
class RequestCore
|
||||
{
|
||||
/**
|
||||
* The URL being requested.
|
||||
*/
|
||||
public $request_url;
|
||||
|
||||
/**
|
||||
* The headers being sent in the request.
|
||||
*/
|
||||
public $request_headers;
|
||||
|
||||
/**
|
||||
* The raw response callback headers
|
||||
*/
|
||||
public $response_raw_headers;
|
||||
|
||||
/**
|
||||
* Response body when error occurs
|
||||
*/
|
||||
public $response_error_body;
|
||||
|
||||
/**
|
||||
*The hander of write file
|
||||
*/
|
||||
public $write_file_handle;
|
||||
|
||||
/**
|
||||
* The body being sent in the request.
|
||||
*/
|
||||
public $request_body;
|
||||
|
||||
/**
|
||||
* The response returned by the request.
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* The headers returned by the request.
|
||||
*/
|
||||
public $response_headers;
|
||||
|
||||
/**
|
||||
* The body returned by the request.
|
||||
*/
|
||||
public $response_body;
|
||||
|
||||
/**
|
||||
* The HTTP status code returned by the request.
|
||||
*/
|
||||
public $response_code;
|
||||
|
||||
/**
|
||||
* Additional response data.
|
||||
*/
|
||||
public $response_info;
|
||||
|
||||
/**
|
||||
* The method by which the request is being made.
|
||||
*/
|
||||
public $method;
|
||||
|
||||
/**
|
||||
* Store the proxy settings to use for the request.
|
||||
*/
|
||||
public $proxy = null;
|
||||
|
||||
/**
|
||||
* The username to use for the request.
|
||||
*/
|
||||
public $username = null;
|
||||
|
||||
/**
|
||||
* The password to use for the request.
|
||||
*/
|
||||
public $password = null;
|
||||
|
||||
/**
|
||||
* Custom CURLOPT settings.
|
||||
*/
|
||||
public $curlopts = null;
|
||||
|
||||
/**
|
||||
* The state of debug mode.
|
||||
*/
|
||||
public $debug_mode = false;
|
||||
|
||||
/**
|
||||
* The default class to use for HTTP Requests (defaults to <RequestCore>).
|
||||
*/
|
||||
public $request_class = 'OSS\Http\RequestCore';
|
||||
|
||||
/**
|
||||
* The default class to use for HTTP Responses (defaults to <ResponseCore>).
|
||||
*/
|
||||
public $response_class = 'OSS\Http\ResponseCore';
|
||||
|
||||
/**
|
||||
* Default useragent string to use.
|
||||
*/
|
||||
public $useragent = 'RequestCore/1.4.3';
|
||||
|
||||
/**
|
||||
* File to read from while streaming up.
|
||||
*/
|
||||
public $read_file = null;
|
||||
|
||||
/**
|
||||
* The resource to read from while streaming up.
|
||||
*/
|
||||
public $read_stream = null;
|
||||
|
||||
/**
|
||||
* The size of the stream to read from.
|
||||
*/
|
||||
public $read_stream_size = null;
|
||||
|
||||
/**
|
||||
* The length already read from the stream.
|
||||
*/
|
||||
public $read_stream_read = 0;
|
||||
|
||||
/**
|
||||
* File to write to while streaming down.
|
||||
*/
|
||||
public $write_file = null;
|
||||
|
||||
/**
|
||||
* The resource to write to while streaming down.
|
||||
*/
|
||||
public $write_stream = null;
|
||||
|
||||
/**
|
||||
* Stores the intended starting seek position.
|
||||
*/
|
||||
public $seek_position = null;
|
||||
|
||||
/**
|
||||
* The location of the cacert.pem file to use.
|
||||
*/
|
||||
public $cacert_location = false;
|
||||
|
||||
/**
|
||||
* The state of SSL certificate verification.
|
||||
*/
|
||||
public $ssl_verification = true;
|
||||
|
||||
/**
|
||||
* The user-defined callback function to call when a stream is read from.
|
||||
*/
|
||||
public $registered_streaming_read_callback = null;
|
||||
|
||||
/**
|
||||
* The user-defined callback function to call when a stream is written to.
|
||||
*/
|
||||
public $registered_streaming_write_callback = null;
|
||||
|
||||
/**
|
||||
* The request timeout time, which is 5,184,000 seconds,that is, 6 days by default
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 5184000;
|
||||
|
||||
/**
|
||||
* The connection timeout time, which is 10 seconds by default
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $connect_timeout = 10;
|
||||
|
||||
/*%******************************************************************************************%*/
|
||||
// CONSTANTS
|
||||
|
||||
/**
|
||||
* GET HTTP Method
|
||||
*/
|
||||
const HTTP_GET = 'GET';
|
||||
|
||||
/**
|
||||
* POST HTTP Method
|
||||
*/
|
||||
const HTTP_POST = 'POST';
|
||||
|
||||
/**
|
||||
* PUT HTTP Method
|
||||
*/
|
||||
const HTTP_PUT = 'PUT';
|
||||
|
||||
/**
|
||||
* DELETE HTTP Method
|
||||
*/
|
||||
const HTTP_DELETE = 'DELETE';
|
||||
|
||||
/**
|
||||
* HEAD HTTP Method
|
||||
*/
|
||||
const HTTP_HEAD = 'HEAD';
|
||||
|
||||
|
||||
/*%******************************************************************************************%*/
|
||||
// CONSTRUCTOR/DESTRUCTOR
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destruct the instance. Closes opened file handles.
|
||||
*
|
||||
* @return $this A reference to the current instance.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/*%******************************************************************************************%*/
|
||||
// REQUEST METHODS
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function set_credentials($user, $pass)
|
||||
{
|
||||
$this->username = $user;
|
||||
$this->password = $pass;
|
||||
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.
|
||||
*/
|
||||
public function add_header($key, $value)
|
||||
{
|
||||
$this->request_headers[$key] = $value;
|
||||
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.
|
||||
*/
|
||||
public function remove_header($key)
|
||||
{
|
||||
if (isset($this->request_headers[$key])) {
|
||||
unset($this->request_headers[$key]);
|
||||
}
|
||||
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.
|
||||
*/
|
||||
public function set_method($method)
|
||||
{
|
||||
$this->method = strtoupper($method);
|
||||
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.
|
||||
*/
|
||||
public function set_useragent($ua)
|
||||
{
|
||||
$this->useragent = $ua;
|
||||
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.
|
||||
*/
|
||||
public function set_body($body)
|
||||
{
|
||||
$this->request_body = $body;
|
||||
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.
|
||||
*/
|
||||
public function set_request_url($url)
|
||||
{
|
||||
$this->request_url = $url;
|
||||
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.
|
||||
*/
|
||||
public function set_curlopts($curlopts)
|
||||
{
|
||||
$this->curlopts = $curlopts;
|
||||
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.
|
||||
*/
|
||||
public function set_read_stream_size($size)
|
||||
{
|
||||
$this->read_stream_size = $size;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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 file to read from while streaming up.
|
||||
*
|
||||
* @param string $location (Required) The readable location to read from.
|
||||
* @return $this A reference to the current instance.
|
||||
*/
|
||||
public function set_read_file($location)
|
||||
{
|
||||
$this->read_file = $location;
|
||||
$read_file_handle = fopen($location, 'r');
|
||||
|
||||
return $this->set_read_stream($read_file_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the resource to write to while streaming down.
|
||||
*
|
||||
* @param resource $resource (Required) The writeable resource to write to.
|
||||
* @return $this A reference to the current instance.
|
||||
*/
|
||||
public function set_write_stream($resource)
|
||||
{
|
||||
$this->write_stream = $resource;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the file to write to while streaming down.
|
||||
*
|
||||
* @param string $location (Required) The writeable location to write to.
|
||||
* @return $this A reference to the current instance.
|
||||
*/
|
||||
public function set_write_file($location)
|
||||
{
|
||||
$this->write_file = $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the proxy to use for making requests.
|
||||
*
|
||||
* @param string $proxy (Required) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port`
|
||||
* @return $this A reference to the current instance.
|
||||
*/
|
||||
public function set_proxy($proxy)
|
||||
{
|
||||
$proxy = parse_url($proxy);
|
||||
$proxy['user'] = isset($proxy['user']) ? $proxy['user'] : null;
|
||||
$proxy['pass'] = isset($proxy['pass']) ? $proxy['pass'] : null;
|
||||
$proxy['port'] = isset($proxy['port']) ? $proxy['port'] : null;
|
||||
$this->proxy = $proxy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the intended starting seek position.
|
||||
*
|
||||
* @param integer $position (Required) The byte-position of the stream to begin reading from.
|
||||
* @return $this A reference to the current instance.
|
||||
*/
|
||||
public function set_seek_position($position)
|
||||
{
|
||||
$this->seek_position = isset($position) ? (integer)$position : null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback function that is invoked by cURL for streaming up.
|
||||
*
|
||||
* @param resource $curl_handle (Required) The cURL handle for the request.
|
||||
* @param resource $header_content (Required) The header callback result.
|
||||
* @return headers from a stream.
|
||||
*/
|
||||
public function streaming_header_callback($curl_handle, $header_content)
|
||||
{
|
||||
$code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
|
||||
|
||||
if (isset($this->write_file) && intval($code) / 100 == 2 && !isset($this->write_file_handle))
|
||||
{
|
||||
$this->write_file_handle = fopen($this->write_file, 'w');
|
||||
$this->set_write_stream($this->write_file_handle);
|
||||
}
|
||||
|
||||
$this->response_raw_headers .= $header_content;
|
||||
return strlen($header_content);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a callback function to execute whenever a data stream is read from using
|
||||
* <CFRequest::streaming_read_callback()>.
|
||||
*
|
||||
* The user-defined callback function should accept three arguments:
|
||||
*
|
||||
* <ul>
|
||||
* <li><code>$curl_handle</code> - <code>resource</code> - Required - The cURL handle resource that represents the in-progress transfer.</li>
|
||||
* <li><code>$file_handle</code> - <code>resource</code> - Required - The file handle resource that represents the file on the local file system.</li>
|
||||
* <li><code>$length</code> - <code>integer</code> - Required - The length in kilobytes of the data chunk that was transferred.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param string|array|function $callback (Required) The callback function is called by <php:call_user_func()>, so you can pass the following values: <ul>
|
||||
* <li>The name of a global function to execute, passed as a string.</li>
|
||||
* <li>A method to execute, passed as <code>array('ClassName', 'MethodName')</code>.</li>
|
||||
* <li>An anonymous function (PHP 5.3+).</li></ul>
|
||||
* @return $this A reference to the current instance.
|
||||
*/
|
||||
public function register_streaming_read_callback($callback)
|
||||
{
|
||||
$this->registered_streaming_read_callback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback function to execute whenever a data stream is written to using
|
||||
* <CFRequest::streaming_write_callback()>.
|
||||
*
|
||||
* The user-defined callback function should accept two arguments:
|
||||
*
|
||||
* <ul>
|
||||
* <li><code>$curl_handle</code> - <code>resource</code> - Required - The cURL handle resource that represents the in-progress transfer.</li>
|
||||
* <li><code>$length</code> - <code>integer</code> - Required - The length in kilobytes of the data chunk that was transferred.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param string|array|function $callback (Required) The callback function is called by <php:call_user_func()>, so you can pass the following values: <ul>
|
||||
* <li>The name of a global function to execute, passed as a string.</li>
|
||||
* <li>A method to execute, passed as <code>array('ClassName', 'MethodName')</code>.</li>
|
||||
* <li>An anonymous function (PHP 5.3+).</li></ul>
|
||||
* @return $this A reference to the current instance.
|
||||
*/
|
||||
public function register_streaming_write_callback($callback)
|
||||
{
|
||||
$this->registered_streaming_write_callback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/*%******************************************************************************************%*/
|
||||
// PREPARE, SEND, AND PROCESS REQUEST
|
||||
|
||||
/**
|
||||
* A callback function that is invoked by cURL for streaming up.
|
||||
*
|
||||
* @param resource $curl_handle (Required) The cURL handle for the request.
|
||||
* @param resource $file_handle (Required) The open file handle resource.
|
||||
* @param integer $length (Required) The maximum number of bytes to read.
|
||||
* @return binary Binary data from a stream.
|
||||
*/
|
||||
public function streaming_read_callback($curl_handle, $file_handle, $length)
|
||||
{
|
||||
// Once we've sent as much as we're supposed to send...
|
||||
if ($this->read_stream_read >= $this->read_stream_size) {
|
||||
// Send EOF
|
||||
return '';
|
||||
}
|
||||
|
||||
// If we're at the beginning of an upload and need to seek...
|
||||
if ($this->read_stream_read == 0 && isset($this->seek_position) && $this->seek_position !== ftell($this->read_stream)) {
|
||||
if (fseek($this->read_stream, $this->seek_position) !== 0) {
|
||||
throw new RequestCore_Exception('The stream does not support seeking and is either not at the requested position or the position is unknown.');
|
||||
}
|
||||
}
|
||||
|
||||
$read = fread($this->read_stream, min($this->read_stream_size - $this->read_stream_read, $length)); // Remaining upload data or cURL's requested chunk size
|
||||
$this->read_stream_read += strlen($read);
|
||||
|
||||
$out = $read === false ? '' : $read;
|
||||
|
||||
// Execute callback function
|
||||
if ($this->registered_streaming_read_callback) {
|
||||
call_user_func($this->registered_streaming_read_callback, $curl_handle, $file_handle, $out);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback function that is invoked by cURL for streaming down.
|
||||
*
|
||||
* @param resource $curl_handle (Required) The cURL handle for the request.
|
||||
* @param binary $data (Required) The data to write.
|
||||
* @return integer The number of bytes written.
|
||||
*/
|
||||
public function streaming_write_callback($curl_handle, $data)
|
||||
{
|
||||
$code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
|
||||
|
||||
if (intval($code) / 100 != 2)
|
||||
{
|
||||
$this->response_error_body .= $data;
|
||||
return strlen($data);
|
||||
}
|
||||
|
||||
$length = strlen($data);
|
||||
$written_total = 0;
|
||||
$written_last = 0;
|
||||
|
||||
while ($written_total < $length) {
|
||||
$written_last = fwrite($this->write_stream, substr($data, $written_total));
|
||||
|
||||
if ($written_last === false) {
|
||||
return $written_total;
|
||||
}
|
||||
|
||||
$written_total += $written_last;
|
||||
}
|
||||
|
||||
// Execute callback function
|
||||
if ($this->registered_streaming_write_callback) {
|
||||
call_user_func($this->registered_streaming_write_callback, $curl_handle, $written_total);
|
||||
}
|
||||
|
||||
return $written_total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and adds the details of the cURL request. This can be passed along to a <php:curl_multi_exec()>
|
||||
* function.
|
||||
*
|
||||
* @return resource The handle for the cURL object.
|
||||
*
|
||||
*/
|
||||
public function prep_request()
|
||||
{
|
||||
$curl_handle = curl_init();
|
||||
|
||||
// Set default options.
|
||||
curl_setopt($curl_handle, CURLOPT_URL, $this->request_url);
|
||||
curl_setopt($curl_handle, CURLOPT_FILETIME, true);
|
||||
curl_setopt($curl_handle, CURLOPT_FRESH_CONNECT, false);
|
||||
// curl_setopt($curl_handle, CURLOPT_CLOSEPOLICY, CURLCLOSEPOLICY_LEAST_RECENTLY_USED);
|
||||
curl_setopt($curl_handle, CURLOPT_MAXREDIRS, 5);
|
||||
curl_setopt($curl_handle, CURLOPT_HEADER, true);
|
||||
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl_handle, CURLOPT_TIMEOUT, $this->timeout);
|
||||
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, $this->connect_timeout);
|
||||
curl_setopt($curl_handle, CURLOPT_NOSIGNAL, true);
|
||||
curl_setopt($curl_handle, CURLOPT_REFERER, $this->request_url);
|
||||
curl_setopt($curl_handle, CURLOPT_USERAGENT, $this->useragent);
|
||||
curl_setopt($curl_handle, CURLOPT_HEADERFUNCTION, array($this, 'streaming_header_callback'));
|
||||
curl_setopt($curl_handle, CURLOPT_READFUNCTION, array($this, 'streaming_read_callback'));
|
||||
|
||||
// Verification of the SSL cert
|
||||
if ($this->ssl_verification) {
|
||||
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, true);
|
||||
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
} else {
|
||||
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, false);
|
||||
}
|
||||
|
||||
// chmod the file as 0755
|
||||
if ($this->cacert_location === true) {
|
||||
curl_setopt($curl_handle, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
|
||||
} elseif (is_string($this->cacert_location)) {
|
||||
curl_setopt($curl_handle, CURLOPT_CAINFO, $this->cacert_location);
|
||||
}
|
||||
|
||||
// Debug mode
|
||||
if ($this->debug_mode) {
|
||||
curl_setopt($curl_handle, CURLOPT_VERBOSE, true);
|
||||
}
|
||||
|
||||
// Handle open_basedir & safe mode
|
||||
if (!ini_get('safe_mode') && !ini_get('open_basedir')) {
|
||||
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true);
|
||||
}
|
||||
|
||||
// Enable a proxy connection if requested.
|
||||
if ($this->proxy) {
|
||||
$host = $this->proxy['host'];
|
||||
$host .= ($this->proxy['port']) ? ':' . $this->proxy['port'] : '';
|
||||
curl_setopt($curl_handle, CURLOPT_PROXY, $host);
|
||||
|
||||
if (isset($this->proxy['user']) && isset($this->proxy['pass'])) {
|
||||
curl_setopt($curl_handle, CURLOPT_PROXYUSERPWD, $this->proxy['user'] . ':' . $this->proxy['pass']);
|
||||
}
|
||||
}
|
||||
|
||||
// Set credentials for HTTP Basic/Digest Authentication.
|
||||
if ($this->username && $this->password) {
|
||||
curl_setopt($curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
||||
curl_setopt($curl_handle, CURLOPT_USERPWD, $this->username . ':' . $this->password);
|
||||
}
|
||||
|
||||
// Handle the encoding if we can.
|
||||
if (extension_loaded('zlib')) {
|
||||
curl_setopt($curl_handle, CURLOPT_ENCODING, '');
|
||||
}
|
||||
|
||||
// Process custom headers
|
||||
if (isset($this->request_headers) && count($this->request_headers)) {
|
||||
$temp_headers = array();
|
||||
|
||||
foreach ($this->request_headers as $k => $v) {
|
||||
$temp_headers[] = $k . ': ' . $v;
|
||||
}
|
||||
|
||||
// fix "Expect: 100-continue"
|
||||
$temp_headers[] = 'Expect:';
|
||||
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $temp_headers);
|
||||
}
|
||||
|
||||
switch ($this->method) {
|
||||
case self::HTTP_PUT:
|
||||
//unset($this->read_stream);
|
||||
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, 'PUT');
|
||||
if (isset($this->read_stream)) {
|
||||
if (!isset($this->read_stream_size) || $this->read_stream_size < 0) {
|
||||
throw new RequestCore_Exception('The stream size for the streaming upload cannot be determined.');
|
||||
}
|
||||
curl_setopt($curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size);
|
||||
curl_setopt($curl_handle, CURLOPT_UPLOAD, true);
|
||||
} else {
|
||||
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body);
|
||||
}
|
||||
break;
|
||||
|
||||
case self::HTTP_POST:
|
||||
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, 'POST');
|
||||
if (isset($this->read_stream)) {
|
||||
if (!isset($this->read_stream_size) || $this->read_stream_size < 0) {
|
||||
throw new RequestCore_Exception('The stream size for the streaming upload cannot be determined.');
|
||||
}
|
||||
curl_setopt($curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size);
|
||||
curl_setopt($curl_handle, CURLOPT_UPLOAD, true);
|
||||
} else {
|
||||
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body);
|
||||
}
|
||||
break;
|
||||
|
||||
case self::HTTP_HEAD:
|
||||
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, self::HTTP_HEAD);
|
||||
curl_setopt($curl_handle, CURLOPT_NOBODY, 1);
|
||||
break;
|
||||
|
||||
default: // Assumed GET
|
||||
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, $this->method);
|
||||
if (isset($this->write_stream) || isset($this->write_file)) {
|
||||
curl_setopt($curl_handle, CURLOPT_WRITEFUNCTION, array($this, 'streaming_write_callback'));
|
||||
curl_setopt($curl_handle, CURLOPT_HEADER, false);
|
||||
} else {
|
||||
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Merge in the CURLOPTs
|
||||
if (isset($this->curlopts) && sizeof($this->curlopts) > 0) {
|
||||
foreach ($this->curlopts as $k => $v) {
|
||||
curl_setopt($curl_handle, $k, $v);
|
||||
}
|
||||
}
|
||||
|
||||
return $curl_handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the post-processed cURL data and break it down into useful header/body/info chunks. Uses the
|
||||
* data stored in the `curl_handle` and `response` properties unless replacement data is passed in via
|
||||
* parameters.
|
||||
*
|
||||
* @param resource|\CurlHandle|null|false $curl_handle (Optional) The reference to the already executed cURL request. Receive CurlHandle instance from PHP8.0
|
||||
* @param string $response (Optional) The actual response content itself that needs to be parsed.
|
||||
* @return ResponseCore A <ResponseCore> object containing a parsed HTTP response.
|
||||
*/
|
||||
public function process_response($curl_handle = null, $response = null)
|
||||
{
|
||||
// Accept a custom one if it's passed.
|
||||
if ($curl_handle && $response) {
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
// As long as this came back as a valid resource or CurlHandle instance...
|
||||
if (is_resource($curl_handle) || (is_object($curl_handle) && get_class($curl_handle) === 'CurlHandle')) {
|
||||
// Determine what's what.
|
||||
$header_size = curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE);
|
||||
$this->response_headers = substr($this->response, 0, $header_size);
|
||||
$this->response_body = substr($this->response, $header_size);
|
||||
$this->response_code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
|
||||
$this->response_info = curl_getinfo($curl_handle);
|
||||
|
||||
if (intval($this->response_code) / 100 != 2 && isset($this->write_file))
|
||||
{
|
||||
$this->response_headers = $this->response_raw_headers;
|
||||
$this->response_body = $this->response_error_body;
|
||||
}
|
||||
|
||||
// Parse out the headers
|
||||
$this->response_headers = explode("\r\n\r\n", trim($this->response_headers));
|
||||
$this->response_headers = array_pop($this->response_headers);
|
||||
$this->response_headers = explode("\r\n", $this->response_headers);
|
||||
array_shift($this->response_headers);
|
||||
|
||||
// Loop through and split up the headers.
|
||||
$header_assoc = array();
|
||||
foreach ($this->response_headers as $header) {
|
||||
$kv = explode(': ', $header);
|
||||
$header_assoc[strtolower($kv[0])] = isset($kv[1]) ? $kv[1] : '';
|
||||
}
|
||||
|
||||
// Reset the headers to the appropriate property.
|
||||
$this->response_headers = $header_assoc;
|
||||
$this->response_headers['info'] = $this->response_info;
|
||||
$this->response_headers['info']['method'] = $this->method;
|
||||
|
||||
if ($curl_handle && $response) {
|
||||
return new ResponseCore($this->response_headers, $this->response_body, $this->response_code);
|
||||
}
|
||||
}
|
||||
|
||||
// Return false
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the request, calling necessary utility functions to update built-in properties.
|
||||
*
|
||||
* @param boolean $parse (Optional) Whether to parse the response with ResponseCore or not.
|
||||
* @return string The resulting unparsed data from the request.
|
||||
*/
|
||||
public function send_request($parse = false)
|
||||
{
|
||||
set_time_limit(0);
|
||||
|
||||
$curl_handle = $this->prep_request();
|
||||
$this->response = curl_exec($curl_handle);
|
||||
|
||||
if ($this->response === false) {
|
||||
throw new RequestCore_Exception('cURL error: ' . curl_error($curl_handle) . ' (' . curl_errno($curl_handle) . ')');
|
||||
}
|
||||
|
||||
$parsed_response = $this->process_response($curl_handle, $this->response);
|
||||
|
||||
curl_close($curl_handle);
|
||||
unset($curl_handle);
|
||||
|
||||
if ($parse) {
|
||||
return $parsed_response;
|
||||
}
|
||||
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
/*%******************************************************************************************%*/
|
||||
// RESPONSE METHODS
|
||||
|
||||
/**
|
||||
* Get the HTTP response headers from the request.
|
||||
*
|
||||
* @param string $header (Optional) A specific header value to return. Defaults to all headers.
|
||||
* @return string|array All or selected header values.
|
||||
*/
|
||||
public function get_response_header($header = null)
|
||||
{
|
||||
if ($header) {
|
||||
return $this->response_headers[strtolower($header)];
|
||||
}
|
||||
return $this->response_headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP response body from the request.
|
||||
*
|
||||
* @return string The response body.
|
||||
*/
|
||||
public function get_response_body()
|
||||
{
|
||||
return $this->response_body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP response code from the request.
|
||||
*
|
||||
* @return string The HTTP response code.
|
||||
*/
|
||||
public function get_response_code()
|
||||
{
|
||||
return $this->response_code;
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Http;
|
||||
|
||||
class RequestCore_Exception extends \Exception
|
||||
{
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Http;
|
||||
|
||||
/**
|
||||
* Container for all response-related methods.
|
||||
*/
|
||||
class ResponseCore
|
||||
{
|
||||
/**
|
||||
* Store the HTTP header information.
|
||||
*/
|
||||
public $header;
|
||||
|
||||
/**
|
||||
* Store the SimpleXML response.
|
||||
*/
|
||||
public $body;
|
||||
|
||||
/**
|
||||
* Store the HTTP response code.
|
||||
*/
|
||||
public $status;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function __construct($header, $body, $status = null)
|
||||
{
|
||||
$this->header = $header;
|
||||
$this->body = $body;
|
||||
$this->status = $status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Did we receive the status code we expected?
|
||||
*
|
||||
* @param integer|array $codes (Optional) The status code(s) to expect. Pass an <php:integer> for a single acceptable value, or an <php:array> of integers for multiple acceptable values.
|
||||
* @return boolean Whether we received the expected status code or not.
|
||||
*/
|
||||
public function isOK($codes = array(200, 201, 204, 206))
|
||||
{
|
||||
if (is_array($codes)) {
|
||||
return in_array($this->status, $codes);
|
||||
}
|
||||
|
||||
return $this->status === $codes;
|
||||
}
|
||||
}
|
@ -1,181 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
/**
|
||||
* Bucket information class. This is the type of element in BucketListInfo's
|
||||
*
|
||||
* Class BucketInfo
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class BucketInfo
|
||||
{
|
||||
/**
|
||||
* BucketInfo constructor.
|
||||
*
|
||||
* @param string $location
|
||||
* @param string $name
|
||||
* @param string $createDate
|
||||
*/
|
||||
public function __construct($location = '', $name = '', $createDate = '')
|
||||
{
|
||||
$this->location = $location;
|
||||
$this->createDate = $createDate;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bucket location
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocation()
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bucket name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bucket creation time.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateDate()
|
||||
{
|
||||
return $this->createDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bucket storage class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStorageClass()
|
||||
{
|
||||
return $this->storageClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bucket extranet endpoint.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExtranetEndpoint()
|
||||
{
|
||||
return $this->extranetEndpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bucket intranet endpoint.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIntranetEndpoint()
|
||||
{
|
||||
return $this->intranetEndpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bucket intranet endpoint.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRegion()
|
||||
{
|
||||
return $this->region;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse bucket information from node.
|
||||
*
|
||||
* @param xml $xml
|
||||
* @throws OssException
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXmlNode($xml)
|
||||
{
|
||||
if (isset($xml->Location)) {
|
||||
$this->location = strval($xml->Location);
|
||||
}
|
||||
if (isset($xml->Name)) {
|
||||
$this->name = strval($xml->Name);
|
||||
}
|
||||
if (isset($xml->CreationDate)) {
|
||||
$this->createDate = strval($xml->CreationDate);
|
||||
}
|
||||
if (isset($xml->StorageClass)) {
|
||||
$this->storageClass = strval($xml->StorageClass);
|
||||
}
|
||||
if (isset($xml->ExtranetEndpoint)) {
|
||||
$this->extranetEndpoint = strval($xml->ExtranetEndpoint);
|
||||
}
|
||||
if (isset($xml->IntranetEndpoint)) {
|
||||
$this->intranetEndpoint = strval($xml->IntranetEndpoint);
|
||||
}
|
||||
if (isset($xml->IntranetEndpoint)) {
|
||||
$this->intranetEndpoint = strval($xml->IntranetEndpoint);
|
||||
}
|
||||
if (isset($xml->Region)) {
|
||||
$this->region = strval($xml->Region);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* bucket region
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $location;
|
||||
/**
|
||||
* bucket name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* bucket creation time
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $createDate;
|
||||
|
||||
/**
|
||||
* bucket storage class
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $storageClass;
|
||||
|
||||
/**
|
||||
* bucket extranet endpoint
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $extranetEndpoint;
|
||||
|
||||
/**
|
||||
* bucket intranet endpoint
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $intranetEndpoint;
|
||||
|
||||
/**
|
||||
* bucket region
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $region;
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class BucketListInfo
|
||||
*
|
||||
* It's the type of return value of ListBuckets.
|
||||
*
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class BucketListInfo
|
||||
{
|
||||
/**
|
||||
* BucketListInfo constructor.
|
||||
* @param array $bucketList
|
||||
*/
|
||||
public function __construct(array $bucketList)
|
||||
{
|
||||
$this->bucketList = $bucketList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the BucketInfo list
|
||||
*
|
||||
* @return BucketInfo[]
|
||||
*/
|
||||
public function getBucketList()
|
||||
{
|
||||
return $this->bucketList;
|
||||
}
|
||||
|
||||
/**
|
||||
* BucketInfo list
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $bucketList = array();
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
/**
|
||||
* Bucket stat class.
|
||||
*
|
||||
* Class BucketStat
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class BucketStat
|
||||
{
|
||||
/**
|
||||
* Get storage
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStorage()
|
||||
{
|
||||
return $this->storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getObjectCount()
|
||||
{
|
||||
return $this->objectCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get multipart upload count.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMultipartUploadCount()
|
||||
{
|
||||
return $this->multipartUploadCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse stat from the xml.
|
||||
*
|
||||
* @param string $strXml
|
||||
* @throws OssException
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
if (isset($xml->Storage) ) {
|
||||
$this->storage = intval($xml->Storage);
|
||||
}
|
||||
if (isset($xml->ObjectCount) ) {
|
||||
$this->objectCount = intval($xml->ObjectCount);
|
||||
}
|
||||
if (isset($xml->MultipartUploadCount) ) {
|
||||
$this->multipartUploadCount = intval($xml->MultipartUploadCount);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* current storage
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $storage;
|
||||
/**
|
||||
* object count
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $objectCount;
|
||||
|
||||
/**
|
||||
* multipart upload count
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $multipartUploadCount;
|
||||
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class CnameConfig
|
||||
* @package OSS\Model
|
||||
*
|
||||
* TODO: fix link
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
|
||||
*/
|
||||
class CnameConfig implements XmlConfig
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->cnameList = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @example
|
||||
* array(2) {
|
||||
* [0]=>
|
||||
* array(3) {
|
||||
* ["Domain"]=>
|
||||
* string(11) "www.foo.com"
|
||||
* ["Status"]=>
|
||||
* string(7) "enabled"
|
||||
* ["LastModified"]=>
|
||||
* string(8) "20150101"
|
||||
* }
|
||||
* [1]=>
|
||||
* array(3) {
|
||||
* ["Domain"]=>
|
||||
* string(7) "bar.com"
|
||||
* ["Status"]=>
|
||||
* string(8) "disabled"
|
||||
* ["LastModified"]=>
|
||||
* string(8) "20160101"
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public function getCnames()
|
||||
{
|
||||
return $this->cnameList;
|
||||
}
|
||||
|
||||
|
||||
public function addCname($cname)
|
||||
{
|
||||
if (count($this->cnameList) >= self::OSS_MAX_RULES) {
|
||||
throw new OssException(
|
||||
"num of cname in the config exceeds self::OSS_MAX_RULES: " . strval(self::OSS_MAX_RULES));
|
||||
}
|
||||
$this->cnameList[] = array('Domain' => $cname);
|
||||
}
|
||||
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
if (!isset($xml->Cname)) return;
|
||||
foreach ($xml->Cname as $entry) {
|
||||
$cname = array();
|
||||
foreach ($entry as $key => $value) {
|
||||
$cname[strval($key)] = strval($value);
|
||||
}
|
||||
$this->cnameList[] = $cname;
|
||||
}
|
||||
}
|
||||
|
||||
public function serializeToXml()
|
||||
{
|
||||
$strXml = <<<EOF
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<BucketCnameConfiguration>
|
||||
</BucketCnameConfiguration>
|
||||
EOF;
|
||||
$xml = new \SimpleXMLElement($strXml);
|
||||
foreach ($this->cnameList as $cname) {
|
||||
$node = $xml->addChild('Cname');
|
||||
foreach ($cname as $key => $value) {
|
||||
$node->addChild($key, $value);
|
||||
}
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
const OSS_MAX_RULES = 10;
|
||||
|
||||
private $cnameList = array();
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class CorsConfig
|
||||
* @package OSS\Model
|
||||
*
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
|
||||
*/
|
||||
class CorsConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* CorsConfig constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->rules = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get CorsRule list
|
||||
*
|
||||
* @return CorsRule[]
|
||||
*/
|
||||
public function getRules()
|
||||
{
|
||||
return $this->rules;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new CorsRule
|
||||
*
|
||||
* @param CorsRule $rule
|
||||
* @throws OssException
|
||||
*/
|
||||
public function addRule($rule)
|
||||
{
|
||||
if (count($this->rules) >= self::OSS_MAX_RULES) {
|
||||
throw new OssException("num of rules in the config exceeds self::OSS_MAX_RULES: " . strval(self::OSS_MAX_RULES));
|
||||
}
|
||||
$this->rules[] = $rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse CorsConfig from the xml.
|
||||
*
|
||||
* @param string $strXml
|
||||
* @throws OssException
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
if (!isset($xml->CORSRule)) return;
|
||||
foreach ($xml->CORSRule as $rule) {
|
||||
$corsRule = new CorsRule();
|
||||
foreach ($rule as $key => $value) {
|
||||
if ($key === self::OSS_CORS_ALLOWED_HEADER) {
|
||||
$corsRule->addAllowedHeader(strval($value));
|
||||
} elseif ($key === self::OSS_CORS_ALLOWED_METHOD) {
|
||||
$corsRule->addAllowedMethod(strval($value));
|
||||
} elseif ($key === self::OSS_CORS_ALLOWED_ORIGIN) {
|
||||
$corsRule->addAllowedOrigin(strval($value));
|
||||
} elseif ($key === self::OSS_CORS_EXPOSE_HEADER) {
|
||||
$corsRule->addExposeHeader(strval($value));
|
||||
} elseif ($key === self::OSS_CORS_MAX_AGE_SECONDS) {
|
||||
$corsRule->setMaxAgeSeconds(strval($value));
|
||||
}
|
||||
}
|
||||
$this->addRule($corsRule);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the object into xml string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><CORSConfiguration></CORSConfiguration>');
|
||||
foreach ($this->rules as $rule) {
|
||||
$xmlRule = $xml->addChild('CORSRule');
|
||||
$rule->appendToXml($xmlRule);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
const OSS_CORS_ALLOWED_ORIGIN = 'AllowedOrigin';
|
||||
const OSS_CORS_ALLOWED_METHOD = 'AllowedMethod';
|
||||
const OSS_CORS_ALLOWED_HEADER = 'AllowedHeader';
|
||||
const OSS_CORS_EXPOSE_HEADER = 'ExposeHeader';
|
||||
const OSS_CORS_MAX_AGE_SECONDS = 'MaxAgeSeconds';
|
||||
const OSS_MAX_RULES = 10;
|
||||
|
||||
/**
|
||||
* CorsRule list
|
||||
*
|
||||
* @var CorsRule[]
|
||||
*/
|
||||
private $rules = array();
|
||||
}
|
@ -1,150 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
|
||||
/**
|
||||
* Class CorsRule
|
||||
* @package OSS\Model
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
|
||||
*/
|
||||
class CorsRule
|
||||
{
|
||||
/**
|
||||
* Add an allowedOrigin rule
|
||||
*
|
||||
* @param string $allowedOrigin
|
||||
*/
|
||||
public function addAllowedOrigin($allowedOrigin)
|
||||
{
|
||||
if (!empty($allowedOrigin)) {
|
||||
$this->allowedOrigins[] = $allowedOrigin;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an allowedMethod rule
|
||||
*
|
||||
* @param string $allowedMethod
|
||||
*/
|
||||
public function addAllowedMethod($allowedMethod)
|
||||
{
|
||||
if (!empty($allowedMethod)) {
|
||||
$this->allowedMethods[] = $allowedMethod;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an allowedHeader rule
|
||||
*
|
||||
* @param string $allowedHeader
|
||||
*/
|
||||
public function addAllowedHeader($allowedHeader)
|
||||
{
|
||||
if (!empty($allowedHeader)) {
|
||||
$this->allowedHeaders[] = $allowedHeader;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an exposeHeader rule
|
||||
*
|
||||
* @param string $exposeHeader
|
||||
*/
|
||||
public function addExposeHeader($exposeHeader)
|
||||
{
|
||||
if (!empty($exposeHeader)) {
|
||||
$this->exposeHeaders[] = $exposeHeader;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxAgeSeconds()
|
||||
{
|
||||
return $this->maxAgeSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $maxAgeSeconds
|
||||
*/
|
||||
public function setMaxAgeSeconds($maxAgeSeconds)
|
||||
{
|
||||
$this->maxAgeSeconds = $maxAgeSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AllowedHeaders list
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAllowedHeaders()
|
||||
{
|
||||
return $this->allowedHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AllowedOrigins list
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAllowedOrigins()
|
||||
{
|
||||
return $this->allowedOrigins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AllowedMethods list
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAllowedMethods()
|
||||
{
|
||||
return $this->allowedMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ExposeHeaders list
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getExposeHeaders()
|
||||
{
|
||||
return $this->exposeHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize all the rules into the xml represented by parameter $xmlRule
|
||||
*
|
||||
* @param \SimpleXMLElement $xmlRule
|
||||
* @throws OssException
|
||||
*/
|
||||
public function appendToXml(&$xmlRule)
|
||||
{
|
||||
if (!isset($this->maxAgeSeconds)) {
|
||||
throw new OssException("maxAgeSeconds is not set in the Rule");
|
||||
}
|
||||
foreach ($this->allowedOrigins as $allowedOrigin) {
|
||||
$xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_ORIGIN, $allowedOrigin);
|
||||
}
|
||||
foreach ($this->allowedMethods as $allowedMethod) {
|
||||
$xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_METHOD, $allowedMethod);
|
||||
}
|
||||
foreach ($this->allowedHeaders as $allowedHeader) {
|
||||
$xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_HEADER, $allowedHeader);
|
||||
}
|
||||
foreach ($this->exposeHeaders as $exposeHeader) {
|
||||
$xmlRule->addChild(CorsConfig::OSS_CORS_EXPOSE_HEADER, $exposeHeader);
|
||||
}
|
||||
$xmlRule->addChild(CorsConfig::OSS_CORS_MAX_AGE_SECONDS, strval($this->maxAgeSeconds));
|
||||
}
|
||||
|
||||
private $allowedHeaders = array();
|
||||
private $allowedOrigins = array();
|
||||
private $allowedMethods = array();
|
||||
private $exposeHeaders = array();
|
||||
private $maxAgeSeconds = null;
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class DeleteMarkerInfo
|
||||
*
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class DeleteMarkerInfo
|
||||
{
|
||||
/**
|
||||
* DeleteMarkerInfo constructor.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $versionId
|
||||
* @param string $lastModified
|
||||
* @param string $isLatest
|
||||
*/
|
||||
public function __construct($key, $versionId, $lastModified, $isLatest)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->versionId = $versionId;
|
||||
$this->lastModified = $lastModified;
|
||||
$this->isLatest = $isLatest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersionId()
|
||||
{
|
||||
return $this->versionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModified()
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIsLatest()
|
||||
{
|
||||
return $this->isLatest;
|
||||
}
|
||||
|
||||
private $key = "";
|
||||
private $versionId = "";
|
||||
private $lastModified = "";
|
||||
private $isLatest = "";
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class DeleteObjectInfo
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class DeleteObjectInfo
|
||||
{
|
||||
/**
|
||||
* DeleteObjectInfo constructor.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $versionId
|
||||
*/
|
||||
public function __construct($key, $versionId = '')
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->versionId = $versionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersionId()
|
||||
{
|
||||
return $this->versionId;
|
||||
}
|
||||
|
||||
private $key = "";
|
||||
private $versionId = "";
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class DeletedObjectInfo
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class DeletedObjectInfo
|
||||
{
|
||||
/**
|
||||
* DeletedObjectInfo constructor.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $versionId
|
||||
* @param string $deleteMarker
|
||||
* @param string $deleteMarkerVersionId
|
||||
*/
|
||||
public function __construct($key, $versionId, $deleteMarker, $deleteMarkerVersionId)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->versionId = $versionId;
|
||||
$this->deleteMarker = $deleteMarker;
|
||||
$this->deleteMarkerVersionId = $deleteMarkerVersionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersionId()
|
||||
{
|
||||
return $this->versionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDeleteMarker()
|
||||
{
|
||||
return $this->deleteMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDeleteMarkerVersionId()
|
||||
{
|
||||
return $this->deleteMarkerVersionId;
|
||||
}
|
||||
|
||||
private $key = "";
|
||||
private $versionId = "";
|
||||
private $deleteMarker = "";
|
||||
private $deleteMarkerVersionId = "";
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class ExtendWormConfig
|
||||
* @package OSS\Model
|
||||
*
|
||||
*/
|
||||
class ExtendWormConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* ExtendWormConfig constructor.
|
||||
* @param null $day
|
||||
*/
|
||||
public function __construct($day = null)
|
||||
{
|
||||
$this->day = $day;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse ExtendWormConfig from the xml.
|
||||
*
|
||||
* @param string $strXml
|
||||
* @throws OssException
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
throw new OssException("Not implemented.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the object into xml string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><ExtendWormConfiguration></ExtendWormConfiguration>');
|
||||
if (isset($this->day)) {
|
||||
$xml->addChild('RetentionPeriodInDays', $this->day);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDay()
|
||||
{
|
||||
return $this->day;
|
||||
}
|
||||
|
||||
private $day = 0;
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class GetLiveChannelHistory
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class GetLiveChannelHistory implements XmlConfig
|
||||
{
|
||||
public function getLiveRecordList()
|
||||
{
|
||||
return $this->liveRecordList;
|
||||
}
|
||||
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
|
||||
if (isset($xml->LiveRecord)) {
|
||||
foreach ($xml->LiveRecord as $record) {
|
||||
$liveRecord = new LiveChannelHistory();
|
||||
$liveRecord->parseFromXmlNode($record);
|
||||
$this->liveRecordList[] = $liveRecord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function serializeToXml()
|
||||
{
|
||||
throw new OssException("Not implemented.");
|
||||
}
|
||||
|
||||
private $liveRecordList = array();
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
/**
|
||||
* Class GetLiveChannelInfo
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class GetLiveChannelInfo implements XmlConfig
|
||||
{
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getFragDuration()
|
||||
{
|
||||
return $this->fragDuration;
|
||||
}
|
||||
|
||||
public function getFragCount()
|
||||
{
|
||||
return $this->fragCount;
|
||||
}
|
||||
|
||||
public function getPlayListName()
|
||||
{
|
||||
return $this->playlistName;
|
||||
}
|
||||
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
|
||||
$this->description = strval($xml->Description);
|
||||
$this->status = strval($xml->Status);
|
||||
|
||||
if (isset($xml->Target)) {
|
||||
foreach ($xml->Target as $target) {
|
||||
$this->type = strval($target->Type);
|
||||
$this->fragDuration = strval($target->FragDuration);
|
||||
$this->fragCount = strval($target->FragCount);
|
||||
$this->playlistName = strval($target->PlaylistName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function serializeToXml()
|
||||
{
|
||||
throw new OssException("Not implemented.");
|
||||
}
|
||||
|
||||
private $description;
|
||||
private $status;
|
||||
private $type;
|
||||
private $fragDuration;
|
||||
private $fragCount;
|
||||
private $playlistName;
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
/**
|
||||
* Class GetLiveChannelStatus
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class GetLiveChannelStatus implements XmlConfig
|
||||
{
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function getConnectedTime()
|
||||
{
|
||||
return $this->connectedTime;
|
||||
}
|
||||
|
||||
public function getRemoteAddr()
|
||||
{
|
||||
return $this->remoteAddr;
|
||||
}
|
||||
|
||||
public function getVideoWidth()
|
||||
{
|
||||
return $this->videoWidth;
|
||||
}
|
||||
public function getVideoHeight()
|
||||
{
|
||||
return $this->videoHeight;
|
||||
}
|
||||
public function getVideoFrameRate()
|
||||
{
|
||||
return $this->videoFrameRate;
|
||||
}
|
||||
public function getVideoBandwidth()
|
||||
{
|
||||
return $this->videoBandwidth;
|
||||
}
|
||||
public function getVideoCodec()
|
||||
{
|
||||
return $this->videoCodec;
|
||||
}
|
||||
|
||||
public function getAudioBandwidth()
|
||||
{
|
||||
return $this->audioBandwidth;
|
||||
}
|
||||
public function getAudioSampleRate()
|
||||
{
|
||||
return $this->audioSampleRate;
|
||||
}
|
||||
public function getAudioCodec()
|
||||
{
|
||||
return $this->audioCodec;
|
||||
}
|
||||
|
||||
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
$this->status = strval($xml->Status);
|
||||
$this->connectedTime = strval($xml->ConnectedTime);
|
||||
$this->remoteAddr = strval($xml->RemoteAddr);
|
||||
|
||||
if (isset($xml->Video)) {
|
||||
foreach ($xml->Video as $video) {
|
||||
$this->videoWidth = intval($video->Width);
|
||||
$this->videoHeight = intval($video->Height);
|
||||
$this->videoFrameRate = intval($video->FrameRate);
|
||||
$this->videoBandwidth = intval($video->Bandwidth);
|
||||
$this->videoCodec = strval($video->Codec);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($xml->Video)) {
|
||||
foreach ($xml->Audio as $audio) {
|
||||
$this->audioBandwidth = intval($audio->Bandwidth);
|
||||
$this->audioSampleRate = intval($audio->SampleRate);
|
||||
$this->audioCodec = strval($audio->Codec);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function serializeToXml()
|
||||
{
|
||||
throw new OssException("Not implemented.");
|
||||
}
|
||||
|
||||
private $status;
|
||||
private $connectedTime;
|
||||
private $remoteAddr;
|
||||
|
||||
private $videoWidth;
|
||||
private $videoHeight;
|
||||
private $videoFrameRate;
|
||||
private $videoBandwidth;
|
||||
private $videoCodec;
|
||||
|
||||
private $audioBandwidth;
|
||||
private $audioSampleRate;
|
||||
private $audioCodec;
|
||||
|
||||
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class InitiateWormConfig
|
||||
* @package OSS\Model
|
||||
*
|
||||
*/
|
||||
class InitiateWormConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* InitiateWormConfig constructor.
|
||||
* @param null $day
|
||||
*/
|
||||
public function __construct($day = null)
|
||||
{
|
||||
$this->day = $day;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse InitiateWormConfig from the xml.
|
||||
*
|
||||
* @param string $strXml
|
||||
* @throws OssException
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
throw new OssException("Not implemented.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the object into xml string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><InitiateWormConfiguration></InitiateWormConfiguration>');
|
||||
if (isset($this->day)) {
|
||||
$xml->addChild('RetentionPeriodInDays', $this->day);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDay()
|
||||
{
|
||||
return $this->day;
|
||||
}
|
||||
|
||||
private $day = 0;
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class LifecycleAction
|
||||
* @package OSS\Model
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
|
||||
*/
|
||||
class LifecycleAction
|
||||
{
|
||||
/**
|
||||
* LifecycleAction constructor.
|
||||
* @param string $action
|
||||
* @param string $timeSpec
|
||||
* @param string $timeValue
|
||||
*/
|
||||
public function __construct($action, $timeSpec, $timeValue)
|
||||
{
|
||||
$this->action = $action;
|
||||
$this->timeSpec = $timeSpec;
|
||||
$this->timeValue = $timeValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LifecycleAction
|
||||
*/
|
||||
public function getAction()
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
*/
|
||||
public function setAction($action)
|
||||
{
|
||||
$this->action = $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTimeSpec()
|
||||
{
|
||||
return $this->timeSpec;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $timeSpec
|
||||
*/
|
||||
public function setTimeSpec($timeSpec)
|
||||
{
|
||||
$this->timeSpec = $timeSpec;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTimeValue()
|
||||
{
|
||||
return $this->timeValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $timeValue
|
||||
*/
|
||||
public function setTimeValue($timeValue)
|
||||
{
|
||||
$this->timeValue = $timeValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use appendToXml to insert actions into xml.
|
||||
*
|
||||
* @param \SimpleXMLElement $xmlRule
|
||||
*/
|
||||
public function appendToXml(&$xmlRule)
|
||||
{
|
||||
$xmlAction = $xmlRule->addChild($this->action);
|
||||
$xmlAction->addChild($this->timeSpec, $this->timeValue);
|
||||
}
|
||||
|
||||
private $action;
|
||||
private $timeSpec;
|
||||
private $timeValue;
|
||||
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
|
||||
/**
|
||||
* Class BucketLifecycleConfig
|
||||
* @package OSS\Model
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
|
||||
*/
|
||||
class LifecycleConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* Parse the xml into this object.
|
||||
*
|
||||
* @param string $strXml
|
||||
* @throws OssException
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$this->rules = array();
|
||||
$xml = simplexml_load_string($strXml);
|
||||
if (!isset($xml->Rule)) return;
|
||||
$this->rules = array();
|
||||
foreach ($xml->Rule as $rule) {
|
||||
$id = strval($rule->ID);
|
||||
$prefix = strval($rule->Prefix);
|
||||
$status = strval($rule->Status);
|
||||
$actions = array();
|
||||
foreach ($rule as $key => $value) {
|
||||
if ($key === 'ID' || $key === 'Prefix' || $key === 'Status') continue;
|
||||
$action = $key;
|
||||
$timeSpec = null;
|
||||
$timeValue = null;
|
||||
foreach ($value as $timeSpecKey => $timeValueValue) {
|
||||
$timeSpec = $timeSpecKey;
|
||||
$timeValue = strval($timeValueValue);
|
||||
}
|
||||
$actions[] = new LifecycleAction($action, $timeSpec, $timeValue);
|
||||
}
|
||||
$this->rules[] = new LifecycleRule($id, $prefix, $status, $actions);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serialize the object to xml
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><LifecycleConfiguration></LifecycleConfiguration>');
|
||||
foreach ($this->rules as $rule) {
|
||||
$xmlRule = $xml->addChild('Rule');
|
||||
$rule->appendToXml($xmlRule);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Add a LifecycleRule
|
||||
*
|
||||
* @param LifecycleRule $lifecycleRule
|
||||
* @throws OssException
|
||||
*/
|
||||
public function addRule($lifecycleRule)
|
||||
{
|
||||
if (!isset($lifecycleRule)) {
|
||||
throw new OssException("lifecycleRule is null");
|
||||
}
|
||||
$this->rules[] = $lifecycleRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the object into xml string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all lifecycle rules.
|
||||
*
|
||||
* @return LifecycleRule[]
|
||||
*/
|
||||
public function getRules()
|
||||
{
|
||||
return $this->rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var LifecycleRule[]
|
||||
*/
|
||||
private $rules;
|
||||
}
|
||||
|
||||
|
@ -1,126 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
/**
|
||||
* Class LifecycleRule
|
||||
* @package OSS\Model
|
||||
*
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
|
||||
*/
|
||||
class LifecycleRule
|
||||
{
|
||||
/**
|
||||
* Get Id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id Rule Id
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file prefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a file prefix
|
||||
*
|
||||
* @param string $prefix The file prefix
|
||||
*/
|
||||
public function setPrefix($prefix)
|
||||
{
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Lifecycle status
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Lifecycle status
|
||||
*
|
||||
* @param string $status
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return LifecycleAction[]
|
||||
*/
|
||||
public function getActions()
|
||||
{
|
||||
return $this->actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LifecycleAction[] $actions
|
||||
*/
|
||||
public function setActions($actions)
|
||||
{
|
||||
$this->actions = $actions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* LifecycleRule constructor.
|
||||
*
|
||||
* @param string $id rule Id
|
||||
* @param string $prefix File prefix
|
||||
* @param string $status Rule status, which has the following valid values: [self::LIFECYCLE_STATUS_ENABLED, self::LIFECYCLE_STATUS_DISABLED]
|
||||
* @param LifecycleAction[] $actions
|
||||
*/
|
||||
public function __construct($id, $prefix, $status, $actions)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->prefix = $prefix;
|
||||
$this->status = $status;
|
||||
$this->actions = $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \SimpleXMLElement $xmlRule
|
||||
*/
|
||||
public function appendToXml(&$xmlRule)
|
||||
{
|
||||
$xmlRule->addChild('ID', $this->id);
|
||||
$xmlRule->addChild('Prefix', $this->prefix);
|
||||
$xmlRule->addChild('Status', $this->status);
|
||||
foreach ($this->actions as $action) {
|
||||
$action->appendToXml($xmlRule);
|
||||
}
|
||||
}
|
||||
|
||||
private $id;
|
||||
private $prefix;
|
||||
private $status;
|
||||
private $actions = array();
|
||||
|
||||
const LIFECYCLE_STATUS_ENABLED = 'Enabled';
|
||||
const LIFECYCLE_STATUS_DISABLED = 'Disabled';
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class ListMultipartUploadInfo
|
||||
* @package OSS\Model
|
||||
*
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/ListMultipartUploads.html
|
||||
*/
|
||||
class ListMultipartUploadInfo
|
||||
{
|
||||
/**
|
||||
* ListMultipartUploadInfo constructor.
|
||||
*
|
||||
* @param string $bucket
|
||||
* @param string $keyMarker
|
||||
* @param string $uploadIdMarker
|
||||
* @param string $nextKeyMarker
|
||||
* @param string $nextUploadIdMarker
|
||||
* @param string $delimiter
|
||||
* @param string $prefix
|
||||
* @param int $maxUploads
|
||||
* @param string $isTruncated
|
||||
* @param array $uploads
|
||||
*/
|
||||
public function __construct($bucket, $keyMarker, $uploadIdMarker, $nextKeyMarker, $nextUploadIdMarker, $delimiter, $prefix, $maxUploads, $isTruncated, array $uploads)
|
||||
{
|
||||
$this->bucket = $bucket;
|
||||
$this->keyMarker = $keyMarker;
|
||||
$this->uploadIdMarker = $uploadIdMarker;
|
||||
$this->nextKeyMarker = $nextKeyMarker;
|
||||
$this->nextUploadIdMarker = $nextUploadIdMarker;
|
||||
$this->delimiter = $delimiter;
|
||||
$this->prefix = $prefix;
|
||||
$this->maxUploads = $maxUploads;
|
||||
$this->isTruncated = $isTruncated;
|
||||
$this->uploads = $uploads;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到bucket名称
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBucket()
|
||||
{
|
||||
return $this->bucket;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKeyMarker()
|
||||
{
|
||||
return $this->keyMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUploadIdMarker()
|
||||
{
|
||||
return $this->uploadIdMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNextKeyMarker()
|
||||
{
|
||||
return $this->nextKeyMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNextUploadIdMarker()
|
||||
{
|
||||
return $this->nextUploadIdMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDelimiter()
|
||||
{
|
||||
return $this->delimiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxUploads()
|
||||
{
|
||||
return $this->maxUploads;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIsTruncated()
|
||||
{
|
||||
return $this->isTruncated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UploadInfo[]
|
||||
*/
|
||||
public function getUploads()
|
||||
{
|
||||
return $this->uploads;
|
||||
}
|
||||
|
||||
private $bucket = "";
|
||||
private $keyMarker = "";
|
||||
private $uploadIdMarker = "";
|
||||
private $nextKeyMarker = "";
|
||||
private $nextUploadIdMarker = "";
|
||||
private $delimiter = "";
|
||||
private $prefix = "";
|
||||
private $maxUploads = 0;
|
||||
private $isTruncated = "false";
|
||||
private $uploads = array();
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class ListPartsInfo
|
||||
* @package OSS\Model
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/ListParts.html
|
||||
*/
|
||||
class ListPartsInfo
|
||||
{
|
||||
|
||||
/**
|
||||
* ListPartsInfo constructor.
|
||||
* @param string $bucket
|
||||
* @param string $key
|
||||
* @param string $uploadId
|
||||
* @param int $nextPartNumberMarker
|
||||
* @param int $maxParts
|
||||
* @param string $isTruncated
|
||||
* @param array $listPart
|
||||
*/
|
||||
public function __construct($bucket, $key, $uploadId, $nextPartNumberMarker, $maxParts, $isTruncated, array $listPart)
|
||||
{
|
||||
$this->bucket = $bucket;
|
||||
$this->key = $key;
|
||||
$this->uploadId = $uploadId;
|
||||
$this->nextPartNumberMarker = $nextPartNumberMarker;
|
||||
$this->maxParts = $maxParts;
|
||||
$this->isTruncated = $isTruncated;
|
||||
$this->listPart = $listPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBucket()
|
||||
{
|
||||
return $this->bucket;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUploadId()
|
||||
{
|
||||
return $this->uploadId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNextPartNumberMarker()
|
||||
{
|
||||
return $this->nextPartNumberMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxParts()
|
||||
{
|
||||
return $this->maxParts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIsTruncated()
|
||||
{
|
||||
return $this->isTruncated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getListPart()
|
||||
{
|
||||
return $this->listPart;
|
||||
}
|
||||
|
||||
private $bucket = "";
|
||||
private $key = "";
|
||||
private $uploadId = "";
|
||||
private $nextPartNumberMarker = 0;
|
||||
private $maxParts = 0;
|
||||
private $isTruncated = "";
|
||||
private $listPart = array();
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
/**
|
||||
* Class LiveChannelConfig
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class LiveChannelConfig implements XmlConfig
|
||||
{
|
||||
public function __construct($option = array())
|
||||
{
|
||||
if (isset($option['description'])) {
|
||||
$this->description = $option['description'];
|
||||
}
|
||||
if (isset($option['status'])) {
|
||||
$this->status = $option['status'];
|
||||
}
|
||||
if (isset($option['type'])) {
|
||||
$this->type = $option['type'];
|
||||
}
|
||||
if (isset($option['fragDuration'])) {
|
||||
$this->fragDuration = $option['fragDuration'];
|
||||
}
|
||||
if (isset($option['fragCount'])) {
|
||||
$this->fragCount = $option['fragCount'];
|
||||
}
|
||||
if (isset($option['playListName'])) {
|
||||
$this->playListName = $option['playListName'];
|
||||
}
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getFragDuration()
|
||||
{
|
||||
return $this->fragDuration;
|
||||
}
|
||||
|
||||
public function getFragCount()
|
||||
{
|
||||
return $this->fragCount;
|
||||
}
|
||||
|
||||
public function getPlayListName()
|
||||
{
|
||||
return $this->playListName;
|
||||
}
|
||||
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
$this->description = strval($xml->Description);
|
||||
$this->status = strval($xml->Status);
|
||||
$target = $xml->Target;
|
||||
$this->type = strval($target->Type);
|
||||
$this->fragDuration = intval($target->FragDuration);
|
||||
$this->fragCount = intval($target->FragCount);
|
||||
$this->playListName = strval($target->PlayListName);
|
||||
}
|
||||
|
||||
public function serializeToXml()
|
||||
{
|
||||
$strXml = <<<EOF
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LiveChannelConfiguration>
|
||||
</LiveChannelConfiguration>
|
||||
EOF;
|
||||
$xml = new \SimpleXMLElement($strXml);
|
||||
if (isset($this->description)) {
|
||||
$xml->addChild('Description', $this->description);
|
||||
}
|
||||
|
||||
if (isset($this->status)) {
|
||||
$xml->addChild('Status', $this->status);
|
||||
}
|
||||
|
||||
$node = $xml->addChild('Target');
|
||||
$node->addChild('Type', $this->type);
|
||||
|
||||
if (isset($this->fragDuration)) {
|
||||
$node->addChild('FragDuration', $this->fragDuration);
|
||||
}
|
||||
|
||||
if (isset($this->fragCount)) {
|
||||
$node->addChild('FragCount', $this->fragCount);
|
||||
}
|
||||
|
||||
if (isset($this->playListName)) {
|
||||
$node->addChild('PlayListName', $this->playListName);
|
||||
}
|
||||
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
private $description;
|
||||
private $status = "enabled";
|
||||
private $type;
|
||||
private $fragDuration = 5;
|
||||
private $fragCount = 3;
|
||||
private $playListName = "playlist.m3u8";
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
/**
|
||||
* Class LiveChannelHistory
|
||||
* @package OSS\Model
|
||||
*
|
||||
*/
|
||||
class LiveChannelHistory implements XmlConfig
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function getStartTime()
|
||||
{
|
||||
return $this->startTime;
|
||||
}
|
||||
|
||||
public function getEndTime()
|
||||
{
|
||||
return $this->endTime;
|
||||
}
|
||||
|
||||
public function getRemoteAddr()
|
||||
{
|
||||
return $this->remoteAddr;
|
||||
}
|
||||
|
||||
public function parseFromXmlNode($xml)
|
||||
{
|
||||
if (isset($xml->StartTime)) {
|
||||
$this->startTime = strval($xml->StartTime);
|
||||
}
|
||||
|
||||
if (isset($xml->EndTime)) {
|
||||
$this->endTime = strval($xml->EndTime);
|
||||
}
|
||||
|
||||
if (isset($xml->RemoteAddr)) {
|
||||
$this->remoteAddr = strval($xml->RemoteAddr);
|
||||
}
|
||||
}
|
||||
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
$this->parseFromXmlNode($xml);
|
||||
}
|
||||
|
||||
public function serializeToXml()
|
||||
{
|
||||
throw new OssException("Not implemented.");
|
||||
}
|
||||
|
||||
private $startTime;
|
||||
private $endTime;
|
||||
private $remoteAddr;
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
/**
|
||||
* Class LiveChannelInfo
|
||||
* @package OSS\Model
|
||||
*
|
||||
*/
|
||||
class LiveChannelInfo implements XmlConfig
|
||||
{
|
||||
public function __construct($name = null, $description = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->description = $description;
|
||||
$this->publishUrls = array();
|
||||
$this->playUrls = array();
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getPublishUrls()
|
||||
{
|
||||
return $this->publishUrls;
|
||||
}
|
||||
|
||||
public function getPlayUrls()
|
||||
{
|
||||
return $this->playUrls;
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function getLastModified()
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
public function parseFromXmlNode($xml)
|
||||
{
|
||||
if (isset($xml->Name)) {
|
||||
$this->name = strval($xml->Name);
|
||||
}
|
||||
|
||||
if (isset($xml->Description)) {
|
||||
$this->description = strval($xml->Description);
|
||||
}
|
||||
|
||||
if (isset($xml->Status)) {
|
||||
$this->status = strval($xml->Status);
|
||||
}
|
||||
|
||||
if (isset($xml->LastModified)) {
|
||||
$this->lastModified = strval($xml->LastModified);
|
||||
}
|
||||
|
||||
if (isset($xml->PublishUrls)) {
|
||||
foreach ($xml->PublishUrls as $url) {
|
||||
$this->publishUrls[] = strval($url->Url);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($xml->PlayUrls)) {
|
||||
foreach ($xml->PlayUrls as $url) {
|
||||
$this->playUrls[] = strval($url->Url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
$this->parseFromXmlNode($xml);
|
||||
}
|
||||
|
||||
public function serializeToXml()
|
||||
{
|
||||
throw new OssException("Not implemented.");
|
||||
}
|
||||
|
||||
private $name;
|
||||
private $description;
|
||||
private $publishUrls;
|
||||
private $playUrls;
|
||||
private $status;
|
||||
private $lastModified;
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class LiveChannelListInfo
|
||||
*
|
||||
* The data returned by ListBucketLiveChannels
|
||||
*
|
||||
* @package OSS\Model
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html
|
||||
*/
|
||||
class LiveChannelListInfo implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBucketName()
|
||||
{
|
||||
return $this->bucket;
|
||||
}
|
||||
|
||||
public function setBucketName($name)
|
||||
{
|
||||
$this->bucket = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMarker()
|
||||
{
|
||||
return $this->marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxKeys()
|
||||
{
|
||||
return $this->maxKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getIsTruncated()
|
||||
{
|
||||
return $this->isTruncated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LiveChannelInfo[]
|
||||
*/
|
||||
public function getChannelList()
|
||||
{
|
||||
return $this->channelList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNextMarker()
|
||||
{
|
||||
return $this->nextMarker;
|
||||
}
|
||||
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
|
||||
$this->prefix = strval($xml->Prefix);
|
||||
$this->marker = strval($xml->Marker);
|
||||
$this->maxKeys = intval($xml->MaxKeys);
|
||||
$this->isTruncated = (strval($xml->IsTruncated) == 'true');
|
||||
$this->nextMarker = strval($xml->NextMarker);
|
||||
|
||||
if (isset($xml->LiveChannel)) {
|
||||
foreach ($xml->LiveChannel as $chan) {
|
||||
$channel = new LiveChannelInfo();
|
||||
$channel->parseFromXmlNode($chan);
|
||||
$this->channelList[] = $channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function serializeToXml()
|
||||
{
|
||||
throw new OssException("Not implemented.");
|
||||
}
|
||||
|
||||
private $bucket = '';
|
||||
private $prefix = '';
|
||||
private $marker = '';
|
||||
private $nextMarker = '';
|
||||
private $maxKeys = 100;
|
||||
private $isTruncated = 'false';
|
||||
private $channelList = array();
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
/**
|
||||
* Class LoggingConfig
|
||||
* @package OSS\Model
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLogging.html
|
||||
*/
|
||||
class LoggingConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* LoggingConfig constructor.
|
||||
* @param null $targetBucket
|
||||
* @param null $targetPrefix
|
||||
*/
|
||||
public function __construct($targetBucket = null, $targetPrefix = null)
|
||||
{
|
||||
$this->targetBucket = $targetBucket;
|
||||
$this->targetPrefix = $targetPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $strXml
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
if (!isset($xml->LoggingEnabled)) return;
|
||||
foreach ($xml->LoggingEnabled as $status) {
|
||||
foreach ($status as $key => $value) {
|
||||
if ($key === 'TargetBucket') {
|
||||
$this->targetBucket = strval($value);
|
||||
} elseif ($key === 'TargetPrefix') {
|
||||
$this->targetPrefix = strval($value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize to xml string
|
||||
*
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><BucketLoggingStatus></BucketLoggingStatus>');
|
||||
if (isset($this->targetBucket) && isset($this->targetPrefix)) {
|
||||
$loggingEnabled = $xml->addChild('LoggingEnabled');
|
||||
$loggingEnabled->addChild('TargetBucket', $this->targetBucket);
|
||||
$loggingEnabled->addChild('TargetPrefix', $this->targetPrefix);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTargetBucket()
|
||||
{
|
||||
return $this->targetBucket;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTargetPrefix()
|
||||
{
|
||||
return $this->targetPrefix;
|
||||
}
|
||||
|
||||
private $targetBucket = "";
|
||||
private $targetPrefix = "";
|
||||
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class ObjectInfo
|
||||
*
|
||||
* The element type of ObjectListInfo, which is the return value type of listObjects
|
||||
*
|
||||
* The return value of listObjects includes two arrays
|
||||
* One is the returned ObjectListInfo, which is similar to a file list in a file system.
|
||||
* The other is the returned prefix list, which is similar to a folder list in a file system.
|
||||
*
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class ObjectInfo
|
||||
{
|
||||
/**
|
||||
* ObjectInfo constructor.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $lastModified
|
||||
* @param string $eTag
|
||||
* @param string $type
|
||||
* @param int $size
|
||||
* @param string $storageClass
|
||||
*/
|
||||
public function __construct($key, $lastModified, $eTag, $type, $size, $storageClass)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->lastModified = $lastModified;
|
||||
$this->eTag = $eTag;
|
||||
$this->type = $type;
|
||||
$this->size = $size;
|
||||
$this->storageClass = $storageClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModified()
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getETag()
|
||||
{
|
||||
return $this->eTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStorageClass()
|
||||
{
|
||||
return $this->storageClass;
|
||||
}
|
||||
|
||||
private $key = "";
|
||||
private $lastModified = "";
|
||||
private $eTag = "";
|
||||
private $type = "";
|
||||
private $size = 0;
|
||||
private $storageClass = "";
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class ObjectListInfo
|
||||
*
|
||||
* The class of return value of ListObjects
|
||||
*
|
||||
* @package OSS\Model
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html
|
||||
*/
|
||||
class ObjectListInfo
|
||||
{
|
||||
/**
|
||||
* ObjectListInfo constructor.
|
||||
*
|
||||
* @param string $bucketName
|
||||
* @param string $prefix
|
||||
* @param string $marker
|
||||
* @param string $nextMarker
|
||||
* @param string $maxKeys
|
||||
* @param string $delimiter
|
||||
* @param null $isTruncated
|
||||
* @param array $objectList
|
||||
* @param array $prefixList
|
||||
*/
|
||||
public function __construct($bucketName, $prefix, $marker, $nextMarker, $maxKeys, $delimiter, $isTruncated, array $objectList, array $prefixList)
|
||||
{
|
||||
$this->bucketName = $bucketName;
|
||||
$this->prefix = $prefix;
|
||||
$this->marker = $marker;
|
||||
$this->nextMarker = $nextMarker;
|
||||
$this->maxKeys = $maxKeys;
|
||||
$this->delimiter = $delimiter;
|
||||
$this->isTruncated = $isTruncated;
|
||||
$this->objectList = $objectList;
|
||||
$this->prefixList = $prefixList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBucketName()
|
||||
{
|
||||
return $this->bucketName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMarker()
|
||||
{
|
||||
return $this->marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxKeys()
|
||||
{
|
||||
return $this->maxKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDelimiter()
|
||||
{
|
||||
return $this->delimiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getIsTruncated()
|
||||
{
|
||||
return $this->isTruncated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ObjectInfo list.
|
||||
*
|
||||
* @return ObjectInfo[]
|
||||
*/
|
||||
public function getObjectList()
|
||||
{
|
||||
return $this->objectList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PrefixInfo list
|
||||
*
|
||||
* @return PrefixInfo[]
|
||||
*/
|
||||
public function getPrefixList()
|
||||
{
|
||||
return $this->prefixList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNextMarker()
|
||||
{
|
||||
return $this->nextMarker;
|
||||
}
|
||||
|
||||
private $bucketName = "";
|
||||
private $prefix = "";
|
||||
private $marker = "";
|
||||
private $nextMarker = "";
|
||||
private $maxKeys = 0;
|
||||
private $delimiter = "";
|
||||
private $isTruncated = null;
|
||||
private $objectList = array();
|
||||
private $prefixList = array();
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class ObjectVersionInfo
|
||||
*
|
||||
* The element type of ObjectVersionListInfo, which is the return value type of listObjectVersions
|
||||
*
|
||||
* The return value of listObjectVersions includes three arrays
|
||||
* One is the returned ObjectVersionListInfo, which is similar to a file list in a file system.
|
||||
* The other is the returned prefix list, which is similar to a folder list in a file system.
|
||||
*
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class ObjectVersionInfo
|
||||
{
|
||||
/**
|
||||
* ObjectVersionInfo constructor.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $lastModified
|
||||
* @param string $eTag
|
||||
* @param string $type
|
||||
* @param int $size
|
||||
* @param string $storageClass
|
||||
* @param string $isLatest
|
||||
*/
|
||||
public function __construct($key, $versionId, $lastModified, $eTag, $type, $size, $storageClass, $isLatest)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->versionId = $versionId;
|
||||
$this->lastModified = $lastModified;
|
||||
$this->eTag = $eTag;
|
||||
$this->type = $type;
|
||||
$this->size = $size;
|
||||
$this->storageClass = $storageClass;
|
||||
$this->isLatest = $isLatest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersionId()
|
||||
{
|
||||
return $this->versionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModified()
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getETag()
|
||||
{
|
||||
return $this->eTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStorageClass()
|
||||
{
|
||||
return $this->storageClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIsLatest()
|
||||
{
|
||||
return $this->isLatest;
|
||||
}
|
||||
|
||||
private $key = "";
|
||||
private $versionId = "";
|
||||
private $lastModified = "";
|
||||
private $eTag = "";
|
||||
private $type = "";
|
||||
private $size = 0;
|
||||
private $storageClass = "";
|
||||
private $isLatest = "";
|
||||
}
|
@ -1,162 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class ObjectVersionListInfo
|
||||
*
|
||||
* The class of return value of ListObjectVersions
|
||||
*
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class ObjectVersionListInfo
|
||||
{
|
||||
/**
|
||||
* ObjectVersionListInfo constructor.
|
||||
*
|
||||
* @param string $bucketName
|
||||
* @param string $prefix
|
||||
* @param string $keyMarker
|
||||
* @param string $nextKeyMarker
|
||||
* @param string $versionIdMarker
|
||||
* @param string $nextVersionIdMarker
|
||||
* @param string $maxKeys
|
||||
* @param string $delimiter
|
||||
* @param null $isTruncated
|
||||
* @param array $objectversionList
|
||||
* @param array $deleteMarkerList
|
||||
* @param array $prefixList
|
||||
*/
|
||||
public function __construct($bucketName, $prefix, $keyMarker, $nextKeyMarker, $versionIdMarker, $nextVersionIdMarker
|
||||
, $maxKeys, $delimiter, $isTruncated
|
||||
, array $objectversionList, array $deleteMarkerList, array $prefixList)
|
||||
{
|
||||
$this->bucketName = $bucketName;
|
||||
$this->prefix = $prefix;
|
||||
$this->keyMarker = $keyMarker;
|
||||
$this->nextKeyMarker = $nextKeyMarker;
|
||||
$this->versionIdMarker = $versionIdMarker;
|
||||
$this->nextVersionIdMarker = $nextVersionIdMarker;
|
||||
$this->maxKeys = $maxKeys;
|
||||
$this->delimiter = $delimiter;
|
||||
$this->isTruncated = $isTruncated;
|
||||
$this->objectVersionList = $objectversionList;
|
||||
$this->deleteMarkerList = $deleteMarkerList;
|
||||
$this->prefixList = $prefixList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBucketName()
|
||||
{
|
||||
return $this->bucketName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKeyMarker()
|
||||
{
|
||||
return $this->keyMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNextKeyMarker()
|
||||
{
|
||||
return $this->nextKeyMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersionIdMarker()
|
||||
{
|
||||
return $this->versionIdMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNextVersionIdMarker()
|
||||
{
|
||||
return $this->nextVersionIdMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxKeys()
|
||||
{
|
||||
return $this->maxKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDelimiter()
|
||||
{
|
||||
return $this->delimiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getIsTruncated()
|
||||
{
|
||||
return $this->isTruncated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ObjectVersionInfo list.
|
||||
*
|
||||
* @return ObjectVersionInfo[]
|
||||
*/
|
||||
public function getObjectVersionList()
|
||||
{
|
||||
return $this->objectVersionList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DeleteMarkerInfo list.
|
||||
*
|
||||
* @return DeleteMarkerInfo[]
|
||||
*/
|
||||
public function getDeleteMarkerList()
|
||||
{
|
||||
return $this->deleteMarkerList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PrefixInfo list
|
||||
*
|
||||
* @return PrefixInfo[]
|
||||
*/
|
||||
public function getPrefixList()
|
||||
{
|
||||
return $this->prefixList;
|
||||
}
|
||||
|
||||
private $bucketName = "";
|
||||
private $prefix = "";
|
||||
private $keyMarker = "";
|
||||
private $nextKeyMarker = "";
|
||||
private $versionIdmarker = "";
|
||||
private $nextVersionIdMarker = "";
|
||||
private $maxKeys = 0;
|
||||
private $delimiter = "";
|
||||
private $isTruncated = null;
|
||||
private $objectVersionList = array();
|
||||
private $deleteMarkerList = array();
|
||||
private $prefixList = array();
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class PartInfo
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class PartInfo
|
||||
{
|
||||
/**
|
||||
* PartInfo constructor.
|
||||
*
|
||||
* @param int $partNumber
|
||||
* @param string $lastModified
|
||||
* @param string $eTag
|
||||
* @param int $size
|
||||
*/
|
||||
public function __construct($partNumber, $lastModified, $eTag, $size)
|
||||
{
|
||||
$this->partNumber = $partNumber;
|
||||
$this->lastModified = $lastModified;
|
||||
$this->eTag = $eTag;
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPartNumber()
|
||||
{
|
||||
return $this->partNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModified()
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getETag()
|
||||
{
|
||||
return $this->eTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
private $partNumber = 0;
|
||||
private $lastModified = "";
|
||||
private $eTag = "";
|
||||
private $size = 0;
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class PrefixInfo
|
||||
*
|
||||
* ListObjects return Prefix list of classes
|
||||
* The returned data contains two arrays
|
||||
* One is to get the list of objects【Can be understood as the corresponding file system file list】
|
||||
* One is to get Prefix list【Can be understood as the corresponding file system directory list】
|
||||
*
|
||||
* @package OSS\Model
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html
|
||||
*/
|
||||
class PrefixInfo
|
||||
{
|
||||
/**
|
||||
* PrefixInfo constructor.
|
||||
* @param string $prefix
|
||||
*/
|
||||
public function __construct($prefix)
|
||||
{
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
private $prefix;
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class RefererConfig
|
||||
*
|
||||
* @package OSS\Model
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketReferer.html
|
||||
*/
|
||||
class RefererConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* @param string $strXml
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
if (!isset($xml->AllowEmptyReferer)) return;
|
||||
if (!isset($xml->RefererList)) return;
|
||||
$this->allowEmptyReferer =
|
||||
(strval($xml->AllowEmptyReferer) === 'TRUE' || strval($xml->AllowEmptyReferer) === 'true') ? true : false;
|
||||
|
||||
foreach ($xml->RefererList->Referer as $key => $refer) {
|
||||
$this->refererList[] = strval($refer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* serialize the RefererConfig object into xml string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><RefererConfiguration></RefererConfiguration>');
|
||||
if ($this->allowEmptyReferer) {
|
||||
$xml->addChild('AllowEmptyReferer', 'true');
|
||||
} else {
|
||||
$xml->addChild('AllowEmptyReferer', 'false');
|
||||
}
|
||||
$refererList = $xml->addChild('RefererList');
|
||||
foreach ($this->refererList as $referer) {
|
||||
$refererList->addChild('Referer', $referer);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $allowEmptyReferer
|
||||
*/
|
||||
public function setAllowEmptyReferer($allowEmptyReferer)
|
||||
{
|
||||
$this->allowEmptyReferer = $allowEmptyReferer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $referer
|
||||
*/
|
||||
public function addReferer($referer)
|
||||
{
|
||||
$this->refererList[] = $referer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isAllowEmptyReferer()
|
||||
{
|
||||
return $this->allowEmptyReferer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRefererList()
|
||||
{
|
||||
return $this->refererList;
|
||||
}
|
||||
|
||||
private $allowEmptyReferer = true;
|
||||
private $refererList = array();
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class RequestPaymentConfig
|
||||
* @package OSS\Model
|
||||
*
|
||||
* @link https://help.aliyun.com/document_detail/117914.htm
|
||||
*/
|
||||
class RequestPaymentConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* RequestPaymentConfig constructor.
|
||||
* @param null $payer
|
||||
*/
|
||||
public function __construct($payer = null)
|
||||
{
|
||||
$this->payer = $payer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse ServerSideEncryptionConfig from the xml.
|
||||
*
|
||||
* @param string $strXml
|
||||
* @throws OssException
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
if (isset($xml->Payer)) {
|
||||
$this->payer = strval($xml->Payer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the object into xml string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><RequestPaymentConfiguration></RequestPaymentConfiguration>');
|
||||
if (isset($this->payer)) {
|
||||
$xml->addChild('Payer', $this->payer);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPayer()
|
||||
{
|
||||
return $this->payer;
|
||||
}
|
||||
|
||||
private $payer = "";
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class RestoreConfig
|
||||
* @package OSS\Model
|
||||
*
|
||||
*/
|
||||
class RestoreConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* RestoreConfig constructor.
|
||||
* @param int $day
|
||||
* @param null $tier
|
||||
*/
|
||||
public function __construct($day, $tier = null)
|
||||
{
|
||||
$this->day = $day;
|
||||
$this->tier = $tier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse RestoreConfig from the xml.
|
||||
*
|
||||
* @param string $strXml
|
||||
* @throws OssException
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
throw new OssException("Not implemented.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the object into xml string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><RestoreRequest></RestoreRequest>');
|
||||
$xml->addChild('Days', strval($this->day));
|
||||
if (isset($this->tier)) {
|
||||
$xml_param = $xml->addChild('JobParameters');
|
||||
$xml_param->addChild('Tier', $this->tier);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDay()
|
||||
{
|
||||
return $this->day;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTier()
|
||||
{
|
||||
return $this->tier;
|
||||
}
|
||||
|
||||
private $day = 1;
|
||||
private $tier = 'Standard';
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class ServerSideEncryptionConfig
|
||||
* @package OSS\Model
|
||||
*
|
||||
* @link https://help.aliyun.com/document_detail/117914.htm
|
||||
*/
|
||||
class ServerSideEncryptionConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* ServerSideEncryptionConfig constructor.
|
||||
* @param null $sseAlgorithm
|
||||
* @param null $kmsMasterKeyID
|
||||
*/
|
||||
public function __construct($sseAlgorithm = null, $kmsMasterKeyID = null)
|
||||
{
|
||||
$this->sseAlgorithm = $sseAlgorithm;
|
||||
$this->kmsMasterKeyID = $kmsMasterKeyID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse ServerSideEncryptionConfig from the xml.
|
||||
*
|
||||
* @param string $strXml
|
||||
* @throws OssException
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
if (!isset($xml->ApplyServerSideEncryptionByDefault)) return;
|
||||
foreach ($xml->ApplyServerSideEncryptionByDefault as $default) {
|
||||
foreach ($default as $key => $value) {
|
||||
if ($key === 'SSEAlgorithm') {
|
||||
$this->sseAlgorithm = strval($value);
|
||||
} elseif ($key === 'KMSMasterKeyID') {
|
||||
$this->kmsMasterKeyID = strval($value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the object into xml string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><ServerSideEncryptionRule></ServerSideEncryptionRule>');
|
||||
$default = $xml->addChild('ApplyServerSideEncryptionByDefault');
|
||||
if (isset($this->sseAlgorithm)) {
|
||||
$default->addChild('SSEAlgorithm', $this->sseAlgorithm);
|
||||
}
|
||||
if (isset($this->kmsMasterKeyID)) {
|
||||
$default->addChild('KMSMasterKeyID', $this->kmsMasterKeyID);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSSEAlgorithm()
|
||||
{
|
||||
return $this->sseAlgorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKMSMasterKeyID()
|
||||
{
|
||||
return $this->kmsMasterKeyID;
|
||||
}
|
||||
|
||||
private $sseAlgorithm = "";
|
||||
private $kmsMasterKeyID = "";
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class StorageCapacityConfig
|
||||
*
|
||||
* @package OSS\Model
|
||||
* @link http://docs.alibaba-inc.com/pages/viewpage.action?pageId=271614763
|
||||
*/
|
||||
class StorageCapacityConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* StorageCapacityConfig constructor.
|
||||
*
|
||||
* @param int $storageCapacity
|
||||
*/
|
||||
public function __construct($storageCapacity)
|
||||
{
|
||||
$this->storageCapacity = $storageCapacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not implemented
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
throw new OssException("Not implemented.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize StorageCapacityConfig into xml
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><BucketUserQos></BucketUserQos>');
|
||||
$xml->addChild('StorageCapacity', strval($this->storageCapacity));
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* To string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set storage capacity
|
||||
*
|
||||
* @param int $storageCapacity
|
||||
*/
|
||||
public function setStorageCapacity($storageCapacity)
|
||||
{
|
||||
$this->storageCapacity = $storageCapacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get storage capacity
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStorageCapacity()
|
||||
{
|
||||
return $this->storageCapacity;
|
||||
}
|
||||
|
||||
private $storageCapacity = 0;
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class Tag
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class Tag
|
||||
{
|
||||
/**
|
||||
* Tag constructor.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
*/
|
||||
public function __construct($key, $value)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
private $key = "";
|
||||
private $value = "";
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class TaggingConfig
|
||||
* @package OSS\Model
|
||||
*
|
||||
*/
|
||||
class TaggingConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* TaggingConfig constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->tags = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Tag list
|
||||
*
|
||||
* @return Tag[]
|
||||
*/
|
||||
public function getTags()
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new Tag
|
||||
*
|
||||
* @param Tag $tag
|
||||
* @throws OssException
|
||||
*/
|
||||
public function addTag($tag)
|
||||
{
|
||||
$this->tags[] = $tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse TaggingConfig from the xml.
|
||||
*
|
||||
* @param string $strXml
|
||||
* @throws OssException
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
if (!isset($xml->TagSet) || !isset($xml->TagSet->Tag)) return;
|
||||
foreach ($xml->TagSet->Tag as $tag) {
|
||||
$this->addTag(new Tag($tag->Key, $tag->Value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the object into xml string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><Tagging></Tagging>');
|
||||
$xmlTagSet = $xml->addChild('TagSet');
|
||||
foreach ($this->tags as $tag) {
|
||||
$xmlTag = $xmlTagSet->addChild('Tag');
|
||||
$xmlTag->addChild('Key', strval($tag->getKey()));
|
||||
$xmlTag->addChild('Value', strval($tag->getValue()));
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag list
|
||||
*
|
||||
* @var Tag[]
|
||||
*/
|
||||
private $tags = array();
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Class UploadInfo
|
||||
*
|
||||
* The return value of ListMultipartUpload
|
||||
*
|
||||
* @package OSS\Model
|
||||
*/
|
||||
class UploadInfo
|
||||
{
|
||||
/**
|
||||
* UploadInfo constructor.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $uploadId
|
||||
* @param string $initiated
|
||||
*/
|
||||
public function __construct($key, $uploadId, $initiated)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->uploadId = $uploadId;
|
||||
$this->initiated = $initiated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getKey()
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUploadId()
|
||||
{
|
||||
return $this->uploadId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getInitiated()
|
||||
{
|
||||
return $this->initiated;
|
||||
}
|
||||
|
||||
private $key = "";
|
||||
private $uploadId = "";
|
||||
private $initiated = "";
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class VersioningConfig
|
||||
* @package OSS\Model
|
||||
*
|
||||
*/
|
||||
class VersioningConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* VersioningConfig constructor.
|
||||
* @param null $status
|
||||
*/
|
||||
public function __construct($status = null)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse VersioningConfig from the xml.
|
||||
*
|
||||
* @param string $strXml
|
||||
* @throws OssException
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
if (isset($xml->Status)) {
|
||||
$this->status = strval($xml->Status);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the object into xml string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><VersioningConfiguration></VersioningConfiguration>');
|
||||
if (isset($this->status)) {
|
||||
$xml->addChild('Status', $this->status);
|
||||
}
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
private $status = "";
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
|
||||
/**
|
||||
* Class WebsiteConfig
|
||||
* @package OSS\Model
|
||||
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketWebsite.html
|
||||
*/
|
||||
class WebsiteConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* WebsiteConfig constructor.
|
||||
* @param string $indexDocument
|
||||
* @param string $errorDocument
|
||||
*/
|
||||
public function __construct($indexDocument = "", $errorDocument = "")
|
||||
{
|
||||
$this->indexDocument = $indexDocument;
|
||||
$this->errorDocument = $errorDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $strXml
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
if (isset($xml->IndexDocument) && isset($xml->IndexDocument->Suffix)) {
|
||||
$this->indexDocument = strval($xml->IndexDocument->Suffix);
|
||||
}
|
||||
if (isset($xml->ErrorDocument) && isset($xml->ErrorDocument->Key)) {
|
||||
$this->errorDocument = strval($xml->ErrorDocument->Key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the WebsiteConfig object into xml string.
|
||||
*
|
||||
* @return string
|
||||
* @throws OssException
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><WebsiteConfiguration></WebsiteConfiguration>');
|
||||
$index_document_part = $xml->addChild('IndexDocument');
|
||||
$error_document_part = $xml->addChild('ErrorDocument');
|
||||
$index_document_part->addChild('Suffix', $this->indexDocument);
|
||||
$error_document_part->addChild('Key', $this->errorDocument);
|
||||
return $xml->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIndexDocument()
|
||||
{
|
||||
return $this->indexDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorDocument()
|
||||
{
|
||||
return $this->errorDocument;
|
||||
}
|
||||
|
||||
private $indexDocument = "";
|
||||
private $errorDocument = "";
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class WormConfig
|
||||
* @package OSS\Model
|
||||
*
|
||||
*/
|
||||
class WormConfig implements XmlConfig
|
||||
{
|
||||
/**
|
||||
* Parse WormConfig from the xml.
|
||||
*
|
||||
* @param string $strXml
|
||||
* @throws OssException
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml)
|
||||
{
|
||||
$xml = simplexml_load_string($strXml);
|
||||
if (isset($xml->WormId)) {
|
||||
$this->wormId = strval($xml->WormId);
|
||||
}
|
||||
if (isset($xml->State)) {
|
||||
$this->state = strval($xml->State);
|
||||
}
|
||||
if (isset($xml->RetentionPeriodInDays)) {
|
||||
$this->day = intval($xml->RetentionPeriodInDays);
|
||||
}
|
||||
if (isset($xml->CreationDate)) {
|
||||
$this->creationDate = strval($xml->CreationDate);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the object into xml string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml()
|
||||
{
|
||||
throw new OssException("Not implemented.");
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->serializeToXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getWormId()
|
||||
{
|
||||
return $this->wormId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDay()
|
||||
{
|
||||
return $this->day;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCreationDate()
|
||||
{
|
||||
return $this->creationDate;
|
||||
}
|
||||
|
||||
private $wormId = '';
|
||||
private $state = '';
|
||||
private $creationDate = '';
|
||||
private $day = 0;
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Model;
|
||||
|
||||
/**
|
||||
* Interface XmlConfig
|
||||
* @package OSS\Model
|
||||
*/
|
||||
interface XmlConfig
|
||||
{
|
||||
|
||||
/**
|
||||
* Interface method: Parse the object from the xml.
|
||||
*
|
||||
* @param string $strXml
|
||||
* @return null
|
||||
*/
|
||||
public function parseFromXml($strXml);
|
||||
|
||||
/**
|
||||
* Interface method: Serialize the object into xml.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeToXml();
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* The type of the return value of getBucketAcl, it wraps the data parsed from xml.
|
||||
*
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class AclResult extends Result
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
* @throws OssException
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$content = $this->rawResponse->body;
|
||||
if (empty($content)) {
|
||||
throw new OssException("body is null");
|
||||
}
|
||||
$xml = simplexml_load_string($content);
|
||||
if (isset($xml->AccessControlList->Grant)) {
|
||||
return strval($xml->AccessControlList->Grant);
|
||||
} else {
|
||||
throw new OssException("xml format exception");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
use OSS\Core\OssException;
|
||||
|
||||
/**
|
||||
* Class AppendResult
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class AppendResult extends Result
|
||||
{
|
||||
/**
|
||||
* Get the value of next-append-position from append's response headers
|
||||
*
|
||||
* @return int
|
||||
* @throws OssException
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$header = $this->rawResponse->header;
|
||||
if (isset($header["x-oss-next-append-position"])) {
|
||||
return intval($header["x-oss-next-append-position"]);
|
||||
}
|
||||
throw new OssException("cannot get next-append-position");
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
|
||||
/**
|
||||
* Class BodyResult
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class BodyResult extends Result
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
return empty($this->rawResponse->body) ? "" : $this->rawResponse->body;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
|
||||
/**
|
||||
* Class CallbackResult
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class CallbackResult extends PutSetDeleteResult
|
||||
{
|
||||
protected function isResponseOk()
|
||||
{
|
||||
$status = $this->rawResponse->status;
|
||||
if ((int)(intval($status) / 100) == 2 && (int)(intval($status)) !== 203) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
|
||||
/**
|
||||
* Class CopyObjectResult
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class CopyObjectResult extends Result
|
||||
{
|
||||
/**
|
||||
* @return array()
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$body = $this->rawResponse->body;
|
||||
$xml = simplexml_load_string($body);
|
||||
$result = array();
|
||||
|
||||
if (isset($xml->LastModified)) {
|
||||
$result[] = $xml->LastModified;
|
||||
}
|
||||
if (isset($xml->ETag)) {
|
||||
$result[] = $xml->ETag;
|
||||
}
|
||||
|
||||
return array_merge($result, $this->rawResponse->header);
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
use OSS\Core\OssUtil;
|
||||
use OSS\Model\DeletedObjectInfo;
|
||||
|
||||
/**
|
||||
* Class DeleteObjectVersionsResult
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class DeleteObjectVersionsResult extends Result
|
||||
{
|
||||
/**
|
||||
* @return DeletedObjectInfo[]
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$xml = simplexml_load_string($this->rawResponse->body);
|
||||
$encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : "";
|
||||
return $this->parseDeletedList($xml, $encodingType);
|
||||
}
|
||||
|
||||
private function parseDeletedList($xml, $encodingType)
|
||||
{
|
||||
$retList = array();
|
||||
if (isset($xml->Deleted)) {
|
||||
foreach ($xml->Deleted as $content) {
|
||||
$key = isset($content->Key) ? strval($content->Key) : "";
|
||||
$key = OssUtil::decodeKey($key, $encodingType);
|
||||
$versionId = isset($content->VersionId) ? strval($content->VersionId) : "";
|
||||
$deleteMarker = isset($content->DeleteMarker) ? strval($content->DeleteMarker) : "";
|
||||
$deleteMarkerVersionId = isset($content->DeleteMarkerVersionId) ? strval($content->DeleteMarkerVersionId) : "";
|
||||
$retList[] = new DeletedObjectInfo($key, $versionId, $deleteMarker, $deleteMarkerVersionId);
|
||||
}
|
||||
}
|
||||
return $retList;
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
|
||||
/**
|
||||
* Class DeleteObjectsResult
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class DeleteObjectsResult extends Result
|
||||
{
|
||||
/**
|
||||
* @return array()
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$body = $this->rawResponse->body;
|
||||
$xml = simplexml_load_string($body);
|
||||
$objects = array();
|
||||
|
||||
if (isset($xml->Deleted)) {
|
||||
foreach($xml->Deleted as $deleteKey)
|
||||
$objects[] = $deleteKey->Key;
|
||||
}
|
||||
return $objects;
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
/**
|
||||
* Class ExistResult checks if bucket or object exists, according to the http status in response headers.
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class ExistResult extends Result
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
return intval($this->rawResponse->status) === 200 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the response status is OK according to the http status code.
|
||||
* [200-299]: OK; [404]: Not found. It means the object or bucket is not found--it's a valid response too.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isResponseOk()
|
||||
{
|
||||
$status = $this->rawResponse->status;
|
||||
if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
|
||||
use OSS\Model\ServerSideEncryptionConfig;
|
||||
|
||||
/**
|
||||
* Class GetBucketEncryptionResult
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class GetBucketEncryptionResult extends Result
|
||||
{
|
||||
/**
|
||||
* Parse the ServerSideEncryptionConfig object from the response
|
||||
*
|
||||
* @return ServerSideEncryptionConfig
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$content = $this->rawResponse->body;
|
||||
$config = new ServerSideEncryptionConfig();
|
||||
$config->parseFromXml($content);
|
||||
return $config;
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
use OSS\Core\OssException;
|
||||
use OSS\Model\BucketInfo;
|
||||
|
||||
/**
|
||||
* Class GetBucketResult interface returns the result class, encapsulated
|
||||
* The returned xml data is parsed
|
||||
*
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class GetBucketInfoResult extends Result
|
||||
{
|
||||
/**
|
||||
* Parse data from response
|
||||
*
|
||||
* @return string
|
||||
* @throws OssException
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$content = $this->rawResponse->body;
|
||||
if (empty($content)) {
|
||||
throw new OssException("body is null");
|
||||
}
|
||||
$xml = simplexml_load_string($content);
|
||||
if (isset($xml->Bucket)) {
|
||||
$info = new BucketInfo();
|
||||
$info->parseFromXmlNode($xml->Bucket);
|
||||
return $info;
|
||||
} else {
|
||||
throw new OssException("xml format exception");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
|
||||
use OSS\Model\RequestPaymentConfig;
|
||||
|
||||
/**
|
||||
* Class GetBucketRequestPaymentResult
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class GetBucketRequestPaymentResult extends Result
|
||||
{
|
||||
/**
|
||||
* Parse the RequestPaymentConfig object from the response
|
||||
*
|
||||
* @return RequestPaymentConfig
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$content = $this->rawResponse->body;
|
||||
$config = new RequestPaymentConfig();
|
||||
$config->parseFromXml($content);
|
||||
return $config->getPayer();
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
|
||||
use OSS\Model\BucketStat;
|
||||
|
||||
/**
|
||||
* Class GetRefererResult
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class GetBucketStatResult extends Result
|
||||
{
|
||||
/**
|
||||
* Parse bucket stat data
|
||||
*
|
||||
* @return BucketStat
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$content = $this->rawResponse->body;
|
||||
$stat = new BucketStat();
|
||||
$stat->parseFromXml($content);
|
||||
return $stat;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
|
||||
use OSS\Model\TaggingConfig;
|
||||
|
||||
/**
|
||||
* Class GetBucketTagsResult
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class GetBucketTagsResult extends Result
|
||||
{
|
||||
/**
|
||||
* Parse the TaggingConfig object from the response
|
||||
*
|
||||
* @return TaggingConfig
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$content = $this->rawResponse->body;
|
||||
$config = new TaggingConfig();
|
||||
$config->parseFromXml($content);
|
||||
return $config;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
|
||||
use OSS\Model\VersioningConfig;
|
||||
|
||||
/**
|
||||
* Class GetBucketVersioningResult
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class GetBucketVersioningResult extends Result
|
||||
{
|
||||
/**
|
||||
* Parse the VersioningConfig object from the response
|
||||
*
|
||||
* @return VersioningConfig
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$content = $this->rawResponse->body;
|
||||
$config = new VersioningConfig();
|
||||
$config->parseFromXml($content);
|
||||
return $config->getStatus();
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
|
||||
use OSS\Model\WormConfig;
|
||||
|
||||
/**
|
||||
* Class GetBucketWormResult
|
||||
* @package OSS\Result
|
||||
*/
|
||||
class GetBucketWormResult extends Result
|
||||
{
|
||||
/**
|
||||
* Parse bucket stat data
|
||||
*
|
||||
* @return WormConfig
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$content = $this->rawResponse->body;
|
||||
$config = new WormConfig();
|
||||
$config->parseFromXml($content);
|
||||
return $config;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Result;
|
||||
|
||||
use OSS\Model\CnameConfig;
|
||||
|
||||
class GetCnameResult extends Result
|
||||
{
|
||||
/**
|
||||
* @return CnameConfig
|
||||
*/
|
||||
protected function parseDataFromResponse()
|
||||
{
|
||||
$content = $this->rawResponse->body;
|
||||
$config = new CnameConfig();
|
||||
$config->parseFromXml($content);
|
||||
return $config;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue