1
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->abortMultipartUpload(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'UploadId' => 'string',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials' => array(
|
||||
'secretId' => $secretId,
|
||||
'secretKey' => $secretKey)));
|
||||
$local_path = "/data/exampleobject";
|
||||
try {
|
||||
$result = $cosClient->appendObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'Position' => 0, //追加对象位置
|
||||
'Body' => fopen($local_path, 'rb'),//读取文件内容
|
||||
));
|
||||
/*
|
||||
$result = $cosClient->appendObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'Position' => (integer)$result['Position'], //取出上一个追加文件的对象位置进行追加
|
||||
'Body' => "hello", //文件流
|
||||
));
|
||||
*/
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$blindWatermarkTemplate = new Qcloud\Cos\ImageParamTemplate\BlindWatermarkTemplate();
|
||||
$blindWatermarkTemplate->setImage("http://examplebucket-125000000.cos.ap-beijing.myqcloud.com/shuiyin.jpeg");
|
||||
$blindWatermarkTemplate->setType(2);
|
||||
$blindWatermarkTemplate->setLevel(3);
|
||||
$result = $cosClient->getObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'ImageHandleParam' => $blindWatermarkTemplate->queryString(),
|
||||
'SaveAs' => '/data/exampleobject'
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getBucketAcl(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
$statusCode = $e->getStatusCode(); // 获取错误码
|
||||
$errorMessage = $e->getMessage(); // 获取错误信息
|
||||
$requestId = $e->getRequestId(); // 获取错误的requestId
|
||||
$errorCode = $e->getCosErrorCode(); // 获取错误名称
|
||||
$request = $e->getRequest(); // 获取完整的请求
|
||||
$response = $e->getResponse(); // 获取完整的响应
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$imageMogrTemplate = new Qcloud\Cos\ImageParamTemplate\ImageMogrTemplate();
|
||||
$imageMogrTemplate->thumbnailByScale(50);
|
||||
$imageMogrTemplate->rotate(50);
|
||||
$imageViewTemplate = new Qcloud\Cos\ImageParamTemplate\ImageViewTemplate();
|
||||
$imageViewTemplate->setMode(1);
|
||||
$imageViewTemplate->setWidth(400);
|
||||
$imageViewTemplate->setHeight(600);
|
||||
$imageViewTemplate->setQuality(1, 85);
|
||||
$ciParamTransformation = new Qcloud\Cos\ImageParamTemplate\CIParamTransformation();
|
||||
$ciParamTransformation->addRule($imageMogrTemplate);
|
||||
$ciParamTransformation->addRule($imageViewTemplate);
|
||||
$result = $cosClient->getObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'ImageHandleParam' => $ciParamTransformation->queryString(),
|
||||
'SaveAs' => '/data/exampleobject',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->completeMultipartUpload(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'UploadId' => 'string',
|
||||
'Parts' => array(
|
||||
array(
|
||||
'ETag' => 'string',
|
||||
'PartNumber' => integer,
|
||||
),
|
||||
array(
|
||||
'ETag' => 'string',
|
||||
'PartNumber' => integer,
|
||||
)),
|
||||
// ... repeated
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
$local_path = "/data/exampleobject";
|
||||
try {
|
||||
$result = $cosClient->copy(
|
||||
$bucket = 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
$key = 'exampleobject',
|
||||
$copySource = array(
|
||||
'Region' => '<sourceRegion>',
|
||||
'Bucket' => '<sourceBucket>',
|
||||
'Key' => '<sourceKey>',
|
||||
)
|
||||
);
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->copyObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'CopySource' => 'examplebucket2-125000000.cos.ap-guangzhou.myqcloud.com/exampleobject',
|
||||
'MetadataDirective' => 'Replaced',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$token = "COS_TMPTOKEN"; //"云 API 临时密钥 Token"
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region, //园区
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'timeout' => 10, //超时时间
|
||||
'connect_timeout' => 10, //连接超时时间
|
||||
'ip' => '', //ip
|
||||
'port' => '', //端口
|
||||
'endpoint' => '', //endpoint
|
||||
'domain' => '', //自定义域名
|
||||
'proxy' => '', //代理服务器
|
||||
'retry' => 10, //重试次数
|
||||
'userAgent' => '', //UA
|
||||
'allow_redirects' => false, //是否follow302
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey,
|
||||
'token' => $token,
|
||||
'anonymous' => true, //匿名模式
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->createBucket(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->putObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'folder/',
|
||||
'Body' => "",
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
// start --------------- 使用模版 ----------------- //
|
||||
$result = $cosClient->createMediaConcatJobs(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Tag' => 'Concat',
|
||||
'QueueId' => 'asdadadfafsdkjhfjghdfjg',
|
||||
'CallBack' => 'https://example.com/callback',
|
||||
'Input' => array(
|
||||
'Object' => 'video01.mp4'
|
||||
),
|
||||
'Operation' => array(
|
||||
'TemplateId' => 'asdfafiahfiushdfisdhfuis',
|
||||
'Output' => array(
|
||||
'Region' => $region,
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Object' => 'concat-video02.mp4',
|
||||
),
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
// end --------------- 使用模版 ----------------- //
|
||||
|
||||
// start --------------- 自定义参数 ----------------- //
|
||||
$result = $cosClient->createMediaConcatJobs(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Tag' => 'Concat',
|
||||
'QueueId' => 'asdadadfafsdkjhfjghdfjg',
|
||||
'CallBack' => 'https://example.com/callback',
|
||||
'Input' => array(
|
||||
'Object' => 'video01.mp4'
|
||||
),
|
||||
'Operation' => array(
|
||||
'Output' => array(
|
||||
'Region' => $region,
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Object' => 'concat-video03.mp4',
|
||||
),
|
||||
'ConcatTemplate' => array(
|
||||
'ConcatFragments' => array(
|
||||
array(
|
||||
'Url' => 'https://example.com/video01.mp4',
|
||||
'Mode' => 'Start',
|
||||
// 'StartTime' => '0',
|
||||
// 'EndTime' => '7',
|
||||
),
|
||||
array(
|
||||
'Url' => 'https://example.com/video02.mp4',
|
||||
'Mode' => 'Start',
|
||||
// 'StartTime' => '0',
|
||||
// 'EndTime' => '10',
|
||||
),
|
||||
// ... repeated
|
||||
),
|
||||
'Index' => 1,
|
||||
'Container' => array(
|
||||
'Format' => 'mp4'
|
||||
),
|
||||
'Audio' => array(
|
||||
'Codec' => 'mp3',
|
||||
'Samplerate' => '',
|
||||
'Bitrate' => '',
|
||||
'Channels' => '',
|
||||
),
|
||||
'Video' => array(
|
||||
'Codec' => 'H.264',
|
||||
'Bitrate' => '1000',
|
||||
'Width' => '1280',
|
||||
'Height' => '',
|
||||
'Fps' => '30',
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
// end --------------- 自定义参数 ----------------- //
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
// start --------------- 使用模版 ----------------- //
|
||||
$result = $cosClient->createMediaSnapshotJobs(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Tag' => 'Snapshot',
|
||||
'QueueId' => 'asdadadfafsdkjhfjghdfjg',
|
||||
'CallBack' => 'https://example.com/callback',
|
||||
'Input' => array(
|
||||
'Object' => 'video01.mp4'
|
||||
),
|
||||
'Operation' => array(
|
||||
'TemplateId' => 'asdfafiahfiushdfisdhfuis',
|
||||
'Output' => array(
|
||||
'Region' => $region,
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Object' => 'snapshot-${Number}.jpg',
|
||||
),
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
// end --------------- 使用模版 ----------------- //
|
||||
|
||||
|
||||
// start --------------- 自定义参数 ----------------- //
|
||||
$result = $cosClient->createMediaSnapshotJobs(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Tag' => 'Snapshot',
|
||||
'QueueId' => 'asdadadfafsdkjhfjghdfjg',
|
||||
'CallBack' => 'https://example.com/callback',
|
||||
'Input' => array(
|
||||
'Object' => 'video01.mp4'
|
||||
),
|
||||
'Operation' => array(
|
||||
'Output' => array(
|
||||
'Region' => $region,
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Object' => 'snapshot-${Number}.jpg',
|
||||
),
|
||||
'Snapshot' => array(
|
||||
'Mode' => 'Average',
|
||||
'Start' => 3,
|
||||
'TimeInterval' => '',
|
||||
'Count' => 3,
|
||||
'Width' => '1280',
|
||||
'Height' => '',
|
||||
),
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
// end --------------- 自定义参数 ----------------- //
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
// start --------------- 使用模版 ----------------- //
|
||||
$result = $cosClient->createMediaTranscodeJobs(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Tag' => 'Transcode',
|
||||
'QueueId' => 'asdadadfafsdkjhfjghdfjg',
|
||||
'CallBack' => 'https://example.com/callback',
|
||||
'Input' => array(
|
||||
'Object' => 'video01.mp4'
|
||||
),
|
||||
'Operation' => array(
|
||||
'TemplateId' => 'asdfafiahfiushdfisdhfuis',
|
||||
'Output' => array(
|
||||
'Region' => $region,
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Object' => 'video02.webm',
|
||||
),
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
// end --------------- 使用模版 ----------------- //
|
||||
|
||||
|
||||
// start --------------- 自定义参数 ----------------- //
|
||||
$result = $cosClient->createMediaTranscodeJobs(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Tag' => 'Transcode',
|
||||
'QueueId' => 'asdadadfafsdkjhfjghdfjg',
|
||||
'CallBack' => 'https://example.com/callback',
|
||||
'Input' => array(
|
||||
'Object' => 'video01.mp4'
|
||||
),
|
||||
'Operation' => array(
|
||||
'Output' => array(
|
||||
'Region' => $region,
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Object' => 'video01.mkv',
|
||||
),
|
||||
'Transcode' => array(
|
||||
'Container' => array(
|
||||
'Format' => 'mp4'
|
||||
),
|
||||
'Video' => array(
|
||||
'Codec' => 'H.264',
|
||||
'Profile' => 'high',
|
||||
'Bitrate' => '1000',
|
||||
'Preset' => 'medium',
|
||||
'Width' => '1280',
|
||||
'Fps' => '30',
|
||||
),
|
||||
'Audio' => array(
|
||||
'Codec' => 'aac',
|
||||
'Samplerate' => '44100',
|
||||
'Bitrate' => '128',
|
||||
'Channels' => '4',
|
||||
),
|
||||
'TransConfig' => array(
|
||||
'AdjDarMethod' => 'scale',
|
||||
'IsCheckReso' => 'false',
|
||||
'ResoAdjMethod' => '1',
|
||||
),
|
||||
'TimeInterval' => array(
|
||||
'Start' => '0',
|
||||
'Duration' => '60',
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
// end --------------- 自定义参数 ----------------- //
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->createMultipartUpload(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
/*
|
||||
'CacheControl' => 'string',
|
||||
'ContentDisposition' => 'string',
|
||||
'ContentEncoding' => 'string',
|
||||
'ContentLanguage' => 'string',
|
||||
'ContentLength' => integer,
|
||||
'ContentType' => 'string',
|
||||
'Expires' => 'string',
|
||||
'Metadata' => array(
|
||||
'string' => 'string',
|
||||
),
|
||||
'StorageClass' => 'string'
|
||||
*/
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->deleteBucket(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->deleteBucketCors(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->deleteBucketDomain(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->DeleteBucketGuetzli(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->DeleteBucketImageStyle(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->deleteBucketLifecycle(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->deleteBucketTagging(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->deleteBucketWebsite(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
|
||||
$cos_path = "cos/folder";
|
||||
$nextMarker = '';
|
||||
$isTruncated = true;
|
||||
while ( $isTruncated ) {
|
||||
try {
|
||||
$result = $cosClient->listObjects(
|
||||
['Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Delimiter' => '',
|
||||
'EncodingType' => 'url',
|
||||
'Marker' => $nextMarker,
|
||||
'Prefix' => $cos_path,
|
||||
'MaxKeys' => 1000]
|
||||
);
|
||||
$isTruncated = $result['IsTruncated'];
|
||||
$nextMarker = $result['NextMarker'];
|
||||
foreach ( $result['Contents'] as $content ) {
|
||||
$cos_file_path = $content['Key'];
|
||||
$local_file_path = $content['Key'];
|
||||
// 按照需求自定义拼接下载路径
|
||||
try {
|
||||
$cosClient->deleteObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => $cos_file_path,
|
||||
));
|
||||
echo ( $cos_file_path . "\n" );
|
||||
} catch ( \Exception $e ) {
|
||||
echo( $e );
|
||||
}
|
||||
}
|
||||
} catch ( \Exception $e ) {
|
||||
echo( $e );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->deleteObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->deleteObjectTagging(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
// start --------------- 桶文件审核 ----------------- //
|
||||
$result = $cosClient->detectAudio(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Input' => array(
|
||||
'Object' => 'sound01.mp3',
|
||||
),
|
||||
'Conf' => array(
|
||||
'DetectType' => 'Porn,Terrorism,Politics,Ads',
|
||||
'Callback' => 'https://example.com/callback',
|
||||
'BizType' => '',
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
// end --------------- 桶文件审核 ----------------- //
|
||||
|
||||
// start --------------- 音频文件地址审核 ----------------- //
|
||||
$result = $cosClient->detectAudio(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Input' => array(
|
||||
'Url' => 'https://example.com/test.mp3',
|
||||
),
|
||||
'Conf' => array(
|
||||
'DetectType' => 'Porn,Terrorism,Politics,Ads',
|
||||
'Callback' => 'https://example.com/callback',
|
||||
'BizType' => '',
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
// end --------------- 音频文件地址审核 ----------------- //
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->detectDocument(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Input' => array(
|
||||
'Url' => 'https://example.com/test01.docx',
|
||||
'Type' => 'docx',
|
||||
),
|
||||
'Conf' => array(
|
||||
'DetectType' => 'Porn,Terrorism,Politics,Ads',
|
||||
'Callback' => 'https://example.com/callback/',
|
||||
'BizType' => '',
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->DetectLabel(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
// start --------------- 文本内容审核 ----------------- //
|
||||
$content = '敏感词';
|
||||
$result = $cosClient->detectText(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Input' => array(
|
||||
'Content' => base64_encode($content) // 文本需base64_encode
|
||||
),
|
||||
'Conf' => array(
|
||||
'DetectType' => 'Porn,Terrorism,Politics,Ads', //Porn,Terrorism,Politics,Ads,Illegal,Abuse类型
|
||||
'BizType' => '',
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
// end --------------- 文本内容审核 ----------------- //
|
||||
|
||||
// start --------------- 存储桶文本文件审核 ----------------- //
|
||||
$result = $cosClient->detectText(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Input' => array(
|
||||
'Object' => 'test01.txt'
|
||||
),
|
||||
'Conf' => array(
|
||||
'DetectType' => 'Porn,Terrorism,Politics,Ads',
|
||||
'Callback' => 'https://example.callback.com/test/', // 回调URL
|
||||
'BizType' => '',
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
// end --------------- 存储桶文本文件审核 ----------------- //
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->detectVideo(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Input' => array(
|
||||
'Object' => 'video01.mp4',
|
||||
),
|
||||
'Conf' => array(
|
||||
'DetectType' => 'Porn,Terrorism,Politics,Ads',
|
||||
'Callback' => 'https://example.com/callback',
|
||||
'BizType' => '',
|
||||
'DetectContent' => 1,
|
||||
'CallbackVersion' => 'Detail',
|
||||
'Snapshot' => array(
|
||||
'Mode' => 'Interval',
|
||||
'TimeInterval' => 50,
|
||||
'Count' => '100',
|
||||
),
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
$local_path = "/data/exampleobject";
|
||||
|
||||
$printbar = function($totalSize, $downloadedSize) {
|
||||
printf("downloaded [%d/%d]\n", $downloadedSize, $totalSize);
|
||||
};
|
||||
|
||||
try {
|
||||
$result = $cosClient->download(
|
||||
$bucket = 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
$key = 'exampleobject',
|
||||
$saveAs = $local_path,
|
||||
$options=['Progress' => $printbar, //指定进度条
|
||||
'PartSize' => 10 * 1024 * 1024, //分块大小
|
||||
'Concurrency' => 5, //并发数
|
||||
'ResumableDownload' => true, //是否开启断点续传,默认为false
|
||||
'ResumableTaskFile' => 'tmp.cosresumabletask' //断点文件信息路径,默认为<localpath>.cosresumabletask
|
||||
]
|
||||
);
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
require dirname( __FILE__ ) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = 'SECRETID';
|
||||
//'云 API 密钥 SecretId';
|
||||
$secretKey = 'SECRETKEY';
|
||||
//'云 API 密钥 SecretKey';
|
||||
$region = 'ap-beijing';
|
||||
//设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey
|
||||
)
|
||||
)
|
||||
);
|
||||
$cos_path = 'cos/folder';
|
||||
$nextMarker = '';
|
||||
$isTruncated = true;
|
||||
|
||||
while ( $isTruncated ) {
|
||||
try {
|
||||
$result = $cosClient->listObjects(
|
||||
['Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Delimiter' => '',
|
||||
'EncodingType' => 'url',
|
||||
'Marker' => $nextMarker,
|
||||
'Prefix' => $cos_path,
|
||||
'MaxKeys' => 1000]
|
||||
);
|
||||
} catch ( \Exception $e ) {
|
||||
echo( $e );
|
||||
}
|
||||
$isTruncated = $result['IsTruncated'];
|
||||
$nextMarker = $result['NextMarker'];
|
||||
foreach ( $result['Contents'] as $content ) {
|
||||
$cos_file_path = $content['Key'];
|
||||
$local_file_path = $content['Key'];
|
||||
// 按照需求自定义拼接下载路径
|
||||
try {
|
||||
$result = $cosClient->download(
|
||||
$bucket = 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
$key = $cos_file_path,
|
||||
$saveAs = $local_file_path
|
||||
);
|
||||
echo ( $cos_file_path . "\n" );
|
||||
} catch ( \Exception $e ) {
|
||||
echo( $e );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
$local_path = "/data/exampleobject";
|
||||
try {
|
||||
$blindWatermarkTemplate = new Qcloud\Cos\ImageParamTemplate\BlindWatermarkTemplate();
|
||||
$blindWatermarkTemplate->setPick();
|
||||
$blindWatermarkTemplate->setImage("http://examplebucket-125000000.cos.ap-beijing.myqcloud.com/shuiyin.jpeg");
|
||||
$blindWatermarkTemplate->setType(2);
|
||||
$picOperationsTemplate = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
|
||||
$picOperationsTemplate->setIsPicInfo(1);
|
||||
$picOperationsTemplate->addRule($blindWatermarkTemplate, "resultobject");
|
||||
$result = $cosClient->putObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'Body' => fopen($local_path, 'rb'),
|
||||
'PicOperations' => $picOperationsTemplate->queryString(),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getBucketAcl(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getBucketCors(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getBucketDomain(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->GetBucketGuetzli(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->GetBucketImageStyle(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'StyleName' => 'stylename',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getBucketInvnetory(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Id' => 'string',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getBucketLifecycle(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getBucketLogging(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials' => array(
|
||||
'secretId' => $secretId,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getBucketReferer(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
)
|
||||
);
|
||||
// 请求成功
|
||||
echo($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getBucketTagging(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getBucketWebsite(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getDetectAudioResult(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject', // jobId
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getDetectDocumentResult(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject', // jobId
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getDetectTextResult(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject', // jobId
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getDetectVideoResult(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject', // jobId
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
|
||||
try {
|
||||
$result = $cosClient->GetMediaInfo(
|
||||
array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' =>'exampleobject', //桶中的媒体文件,如test.mp4
|
||||
'ci-process' => 'videoinfo' //操作类型,固定使用 videoinfo
|
||||
)
|
||||
);
|
||||
// 请求成功
|
||||
echo($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'SaveAs' => '/data/exampleobject',
|
||||
/*
|
||||
'Range' => 'bytes=0-10',
|
||||
'ResponseCacheControl' => 'string',
|
||||
'ResponseContentDisposition' => 'string',
|
||||
'ResponseContentEncoding' => 'string',
|
||||
'ResponseContentLanguage' => 'string',
|
||||
'ResponseContentType' => 'string',
|
||||
'ResponseExpires' => 'string',
|
||||
*/
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials' => array(
|
||||
'secretId' => $secretId,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
//存储桶图片审核
|
||||
$result = $cosClient->getObjectSensitiveContentRecognition(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'DetectType' => 'porn,politics', //可选四种参数:porn,politics,terrorist,ads,可使用多种规则,注意规则间不要加空格
|
||||
'ci-process' => 'sensitive-content-recognition',
|
||||
// 'Interval' => 5, // 审核gif时使用 截帧的间隔
|
||||
// 'MaxFrames' => 5, // 针对 GIF 动图审核的最大截帧数量,需大于0。
|
||||
// 'BizType' => '', // 审核策略
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
|
||||
|
||||
//图片链接审核
|
||||
$imgUrl = 'https://test.jpg';
|
||||
$result = $cosClient->getObjectSensitiveContentRecognition(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => '/', // 链接图片资源路径写 / 即可
|
||||
'DetectType' => 'porn,ads',//可选四种参数:porn,politics,terrorist,ads,可使用多种规则,注意规则间不要加空格
|
||||
'DetectUrl' => $imgUrl,
|
||||
'ci-process' => 'sensitive-content-recognition',
|
||||
// 'Interval' => 5, // 审核gif时使用 截帧的间隔
|
||||
// 'MaxFrames' => 5, // 针对 GIF 动图审核的最大截帧数量,需大于0。
|
||||
// 'BizType' => '', // 审核策略
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials' => array(
|
||||
'secretId' => $secretId,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->getObjectTagging(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject'
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials' => array(
|
||||
'secretId' => $secretId,
|
||||
'secretKey' => $secretKey
|
||||
)
|
||||
)
|
||||
);
|
||||
$local_path = "/data/exampleobject";
|
||||
|
||||
try {
|
||||
$bucket = "examplebucket-1250000000"; //存储桶,格式:BucketName-APPID
|
||||
$key = "exampleobject"; //对象在存储桶中的位置,即对象键
|
||||
$signedUrl = $cosClient->getObjectUrl(
|
||||
$bucket,
|
||||
$key,
|
||||
'+10 minutes', //签名的有效时间
|
||||
[
|
||||
'ResponseContentDisposition' => '111',
|
||||
'Params' => [ // Params中可以传自定义querystring
|
||||
'aaa' => 'bbb',
|
||||
'ccc' => 'ddd'
|
||||
],
|
||||
]
|
||||
);
|
||||
// 请求成功
|
||||
echo $signedUrl;
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
print_r($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials' => array(
|
||||
'secretId' => $secretId,
|
||||
'secretKey' => $secretKey)));
|
||||
|
||||
try {
|
||||
$bucket = 'examplebucket-125000000'; //存储桶,格式:BucketName-APPID
|
||||
$key = "exampleobject"; //对象在存储桶中的位置,即对象键
|
||||
$signedUrl = $cosClient -> getObjectUrlWithoutSign($bucket, $key);
|
||||
|
||||
// 请求成功
|
||||
echo $signedUrl;
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
print_r($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
$local_path = "/data/exampleobject";
|
||||
try {
|
||||
$signedUrl = $cosClient->getPresignedUrl(
|
||||
$method='getObject',
|
||||
$args=array(
|
||||
'Bucket'=>'examplebucket-1250000000', //格式:BucketName-APPID
|
||||
'Key'=>'exampleobject',
|
||||
'Body'=>'',
|
||||
'Params'=>array(),
|
||||
'Headers'=>array()),
|
||||
$expires='+30 minutes');
|
||||
// 请求成功
|
||||
echo($signedUrl);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
$time = 3.14;
|
||||
$local_path = "/data/exampleobject/test.jpg";
|
||||
try {
|
||||
/*
|
||||
* 如果访问400,media bucket unbinded, bucket's host is unavailable
|
||||
* 请先在控制台开启媒体处理开关
|
||||
*/
|
||||
$result = $cosClient->getSnapshot(
|
||||
array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' =>'exampleobject', //桶中的媒体文件,如test.mp4
|
||||
'ci-process' => 'snapshot', //操作类型,固定使用 snapshot
|
||||
'Time' => $time, //截图的时间点,单位为秒
|
||||
'SaveAs' => $local_path, //本地保存路径
|
||||
// 'Width' => 0,
|
||||
// 'Height' => 0,
|
||||
// 'Format' => 'jpg',
|
||||
// 'Rotate' => 'auto',
|
||||
// 'Mode' => 'exactframe',
|
||||
)
|
||||
);
|
||||
// 请求成功
|
||||
echo($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->headBucket(array(
|
||||
'Bucket' => 'examplebucket-125000000' //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->headObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->ImageAve(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->ImageExif(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->ImageInfo(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$imageMogrTemplate = new Qcloud\Cos\ImageParamTemplate\ImageMogrTemplate();
|
||||
$imageMogrTemplate->thumbnailByScale(50);
|
||||
$imageMogrTemplate->rotate(50);
|
||||
$result = $cosClient->getObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'ImageHandleParam' => $imageMogrTemplate->queryString(),
|
||||
'SaveAs' => '/data/exampleobject',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$imageMogrTemplate = new Qcloud\Cos\ImageParamTemplate\ImageMogrTemplate();
|
||||
$imageMogrTemplate->thumbnailByScale(50);
|
||||
$picOperationsTemplate = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
|
||||
$picOperationsTemplate->setIsPicInfo(1);
|
||||
$picOperationsTemplate->addRule($imageMogrTemplate, "resultobject");
|
||||
$result = $cosClient->ImageProcess(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'PicOperations' => $picOperationsTemplate->queryString(),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$imageViewTemplate = new Qcloud\Cos\ImageParamTemplate\ImageViewTemplate();
|
||||
$imageViewTemplate->setMode(1);
|
||||
$imageViewTemplate->setWidth(400);
|
||||
$imageViewTemplate->setHeight(600);
|
||||
$imageViewTemplate->setQuality(1, 85);
|
||||
$result = $cosClient->getObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'ImageHandleParam' => $imageViewTemplate->queryString(),
|
||||
'SaveAs' => '/data/exampleobject'
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$imageWatermarkTemplate = new Qcloud\Cos\ImageParamTemplate\ImageWatermarkTemplate();
|
||||
$imageWatermarkTemplate->setImage("http://examplebucket-125000000.cos.ap-beijing.myqcloud.com/shuiyin.jpeg");
|
||||
$imageWatermarkTemplate->setGravity('center');
|
||||
$imageWatermarkTemplate->setDx(10);
|
||||
$imageWatermarkTemplate->setDy(10);
|
||||
$imageWatermarkTemplate->setSpcent(100);
|
||||
$result = $cosClient->getObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'ImageHandleParam' => $imageWatermarkTemplate->queryString(),
|
||||
'SaveAs' => '/data/exampleobject'
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
|
||||
try {
|
||||
$result = $cosClient->listBuckets();
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->listMultipartUploads(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Delimiter' => '/',
|
||||
'EncodingType' => 'url',
|
||||
'KeyMarker' => 'string',
|
||||
'UploadIdMarker' => 'string',
|
||||
'Prefix' => 'prfix',
|
||||
'MaxUploads' => 1000,
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->listObjects(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Delimiter' => '/',
|
||||
'EncodingType' => 'url',
|
||||
'Marker' => 'prefix/picture.jpg',
|
||||
'Prefix' => 'prfix',
|
||||
'MaxKeys' => 1000,
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->listParts(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'UploadId' => 'NWNhNDY0YzFfMmZiNTM1MGFfNTM2YV8xYjliMTg',
|
||||
'PartNumberMarker' => 1,
|
||||
'MaxParts' => 1000,
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
$local_path = "/data/exampleobject";
|
||||
try {
|
||||
$imageMogrTemplate = new Qcloud\Cos\ImageParamTemplate\ImageMogrTemplate();
|
||||
$imageMogrTemplate->thumbnailByScale(50);
|
||||
$picOperationsTemplate = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
|
||||
$picOperationsTemplate->setIsPicInfo(0);
|
||||
$picOperationsTemplate->addRule($imageMogrTemplate, "resultobject");
|
||||
$result = $cosClient->putObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'Body' => fopen($local_path, 'rb'),
|
||||
'PicOperations' => $picOperationsTemplate->queryString(),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
$local_path = "/data/exampleobject";
|
||||
try {
|
||||
$blindWatermarkTemplate = new Qcloud\Cos\ImageParamTemplate\BlindWatermarkTemplate();
|
||||
$blindWatermarkTemplate->setText("Test");
|
||||
$blindWatermarkTemplate->setType(3);
|
||||
$picOperationsTemplate = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
|
||||
$picOperationsTemplate->setIsPicInfo(1);
|
||||
$picOperationsTemplate->addRule($blindWatermarkTemplate, "resultobject");
|
||||
$result = $cosClient->putObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'Body' => fopen($local_path, 'rb'),
|
||||
'PicOperations' => $picOperationsTemplate->queryString(),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->putBucketAcl(array(
|
||||
//bucket的命名规则为{name}-{appid} ,此处填写的存储桶名称必须为此格式
|
||||
'Bucket' => 'examplebucket-125000000',
|
||||
'ACL' => 'private',
|
||||
'Grants' => array(
|
||||
array(
|
||||
'Grantee' => array(
|
||||
'DisplayName' => 'qcs::cam::uin/100000000001:uin/100000000001',
|
||||
'ID' => 'qcs::cam::uin/100000000001:uin/100000000001',
|
||||
'Type' => 'CanonicalUser',
|
||||
),
|
||||
'Permission' => 'FULL_CONTROL',
|
||||
),
|
||||
// ... repeated
|
||||
),
|
||||
'Owner' => array(
|
||||
'DisplayName' => 'qcs::cam::uin/3210232098:uin/3210232098',
|
||||
'ID' => 'qcs::cam::uin/3210232098:uin/3210232098',
|
||||
)));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->putBucketCors(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'CORSRules' => array(
|
||||
array(
|
||||
'ID' => '1234',
|
||||
'AllowedHeaders' => array('*'),
|
||||
'AllowedMethods' => array('PUT'),
|
||||
'AllowedOrigins' => array('http://www.qq.com'),
|
||||
),
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->putBucketDomain(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'DomainRules' => array(
|
||||
array(
|
||||
'Name' => 'www.qq.com',
|
||||
'Status' => 'ENABLED',
|
||||
'Type' => 'REST',
|
||||
'ForcedReplacement' => 'CNAME',
|
||||
),
|
||||
// ... repeated
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->PutBucketGuetzli(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->PutBucketImageStyle(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'StyleName' => 'stylename',
|
||||
'StyleBody' => 'imageMogr2/thumbnail/!50px',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->putBucketInventory(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Id' => 'string',
|
||||
'Destination' => array(
|
||||
'COSBucketDestination'=>array(
|
||||
'Format' => 'CSV',
|
||||
'AccountId' => '125000000',
|
||||
'Bucket' => 'qcs::cos:ap-chengdu::examplebucket-125000000',
|
||||
'Prefix' => 'string',
|
||||
)
|
||||
),
|
||||
'IsEnabled' => 'True',
|
||||
'Schedule' => array(
|
||||
'Frequency' => 'Daily',
|
||||
),
|
||||
'Filter' => array(
|
||||
'Prefix' => 'string',
|
||||
),
|
||||
'IncludedObjectVersions' => 'Current',
|
||||
'OptionalFields' => array(
|
||||
'Size',
|
||||
'ETag',
|
||||
)
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->putBucketLifecycle(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Rules' => array(
|
||||
array(
|
||||
'Expiration' => array(
|
||||
'Days' => integer,
|
||||
),
|
||||
'ID' => 'string',
|
||||
'Filter' => array(
|
||||
'Prefix' => 'string'
|
||||
),
|
||||
'Status' => 'string',
|
||||
'Transitions' => array(
|
||||
array(
|
||||
'Days' => integer,
|
||||
'StorageClass' => 'string'
|
||||
),
|
||||
// ... repeated
|
||||
),
|
||||
),
|
||||
// ... repeated
|
||||
)
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->putBucketLogging(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'LoggingEnabled' => array(
|
||||
'TargetBucket' => 'examplebucket2-125000000', //格式:BucketName-APPID
|
||||
'TargetPrefix' => '',
|
||||
)
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials' => array(
|
||||
'secretId' => $secretId,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->putBucketReferer(
|
||||
array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Status' => 'Enabled', //是否开启防盗链,枚举值:Enabled、Disabled
|
||||
'RefererType' => 'White-List', //防盗链类型,枚举值:Black-List、White-List
|
||||
'DomainList' => array(
|
||||
'Domains' => array(
|
||||
'*.qq.com',
|
||||
'*.qcloud.com',
|
||||
)
|
||||
), //生效域名列表
|
||||
// 'EmptyReferConfiguration' => 'Allow',//是否允许空 Referer 访问,枚举值:Allow、Deny,默认值为 Deny
|
||||
)
|
||||
);
|
||||
// 请求成功
|
||||
echo($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->putBucketTagging(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'TagSet' => array(
|
||||
array('Key'=>'key1',
|
||||
'Value'=>'value1',
|
||||
),
|
||||
array('Key'=>'key2',
|
||||
'Value'=>'value2',
|
||||
),
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
|
||||
try {
|
||||
$result = $cosClient->putBucketWebsite(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'IndexDocument' => array(
|
||||
'Suffix' => 'index.html',
|
||||
),
|
||||
'RedirectAllRequestsTo' => array(
|
||||
'Protocol' => 'https',
|
||||
),
|
||||
'ErrorDocument' => array(
|
||||
'Key' => 'Error.html',
|
||||
),
|
||||
'RoutingRules' => array(
|
||||
array(
|
||||
'Condition' => array(
|
||||
'HttpErrorCodeReturnedEquals' => '405',
|
||||
),
|
||||
'Redirect' => array(
|
||||
'Protocol' => 'https',
|
||||
'ReplaceKeyWith' => '404.html',
|
||||
),
|
||||
),
|
||||
// ... repeated
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
$local_path = "/data/exampleobject";
|
||||
try {
|
||||
$imageStyleTemplate = new Qcloud\Cos\ImageParamTemplate\ImageStyleTemplate();
|
||||
$imageStyleTemplate->setStyle("stylename");
|
||||
$picOperationsTemplate = new \Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
|
||||
$picOperationsTemplate->setIsPicInfo(1);
|
||||
$picOperationsTemplate->addRule($imageStyleTemplate, "resultobject");
|
||||
$result = $cosClient->putObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'Body' => fopen($local_path, 'rb'),
|
||||
'PicOperations' => $picOperationsTemplate->queryString(),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
$local_path = "/data/exampleobject";
|
||||
//添加tagging
|
||||
/*$tagSet = http_build_query( array(
|
||||
urlencode("key1") => urlencode("value1"),
|
||||
urlencode("key2") => urlencode("value2")),
|
||||
'',
|
||||
'&'
|
||||
); */
|
||||
try {
|
||||
$result = $cosClient->putObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'Body' => fopen($local_path, 'rb'),
|
||||
/*
|
||||
'CacheControl' => 'string',
|
||||
'ContentDisposition' => 'string',
|
||||
'ContentEncoding' => 'string',
|
||||
'ContentLanguage' => 'string',
|
||||
'ContentLength' => integer,
|
||||
'ContentType' => 'string',
|
||||
'Expires' => 'string',
|
||||
'Metadata' => array(
|
||||
'string' => 'string',
|
||||
),
|
||||
'StorageClass' => 'string',
|
||||
'Tagging' => $tagSet //最多10个标签
|
||||
*/
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->putObjectTagging(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'TagSet' => array(
|
||||
array('Key'=>'key1',
|
||||
'Value'=>'value1',
|
||||
),
|
||||
array('Key'=>'key2',
|
||||
'Value'=>'value2',
|
||||
),
|
||||
),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo "$e\n";
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
$local_path = "/data/exampleobject";
|
||||
try {
|
||||
$imageQrcodeTemplate = new Qcloud\Cos\ImageParamTemplate\ImageQrcodeTemplate();
|
||||
$imageQrcodeTemplate->setMode(0);
|
||||
$picOperationsTemplate = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation();
|
||||
$picOperationsTemplate->setIsPicInfo(1);
|
||||
$picOperationsTemplate->addRule($imageQrcodeTemplate, "resultobject");
|
||||
$result = $cosClient->putObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'Body' => fopen($local_path, 'rb'),
|
||||
'PicOperations' => $picOperationsTemplate->queryString(),
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->Qrcode(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'Cover' => 0,
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->QrcodeGenerate(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'QrcodeContent' => '<https://www.baidu.com>',
|
||||
'QrcodeMode' => 0,
|
||||
'QrcodeWidth' => '200',
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->restoreObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'Days' => integer,
|
||||
'CASJobParameters' => array(
|
||||
'Tier' =>'string'
|
||||
)
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey
|
||||
)
|
||||
));
|
||||
try {
|
||||
$result = $cosClient->selectObjectContent(array(
|
||||
'Bucket' => $bucket, //格式:BucketName-APPID
|
||||
'Key' => $key,
|
||||
'Expression' => 'Select * from COSObject s',
|
||||
'ExpressionType' => 'SQL',
|
||||
'InputSerialization' => array(
|
||||
'CompressionType' => 'None',
|
||||
'CSV' => array(
|
||||
'FileHeaderInfo' => 'NONE',
|
||||
'RecordDelimiter' => '\n',
|
||||
'FieldDelimiter' => ',',
|
||||
'QuoteEscapeCharacter' => '"',
|
||||
'Comments' => '#',
|
||||
'AllowQuotedRecordDelimiter' => 'FALSE'
|
||||
)
|
||||
),
|
||||
'OutputSerialization' => array(
|
||||
'CSV' => array(
|
||||
'QuoteField' => 'ASNEEDED',
|
||||
'RecordDelimiter' => '\n',
|
||||
'FieldDelimiter' => ',',
|
||||
'QuoteCharacter' => '"',
|
||||
'QuoteEscapeCharacter' => '"'
|
||||
)
|
||||
),
|
||||
'RequestProgress' => array(
|
||||
'Enabled' => 'FALSE'
|
||||
)
|
||||
));
|
||||
// 请求成功
|
||||
foreach ($result['Data'] as $data) {
|
||||
// 迭代遍历select结果
|
||||
print_r($data);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
try {
|
||||
$result = $cosClient->selectObjectContent(array(
|
||||
'Bucket' => $bucket, //格式:BucketName-APPID
|
||||
'Key' => $key,
|
||||
'Expression' => 'Select * from COSObject s',
|
||||
'ExpressionType' => 'SQL',
|
||||
'InputSerialization' => array(
|
||||
'CompressionType' => 'None',
|
||||
'JSON' => array(
|
||||
'Type' => 'DOCUMENT'
|
||||
)
|
||||
),
|
||||
'OutputSerialization' => array(
|
||||
'JSON' => array(
|
||||
'RecordDelimiter' => '\n',
|
||||
)
|
||||
),
|
||||
'RequestProgress' => array(
|
||||
'Enabled' => 'FALSE'
|
||||
)
|
||||
));
|
||||
// 请求成功
|
||||
foreach ($result['Data'] as $data) {
|
||||
// 迭代遍历select结果
|
||||
print_r($data);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$textWatermarkTemplate = new Qcloud\Cos\ImageParamTemplate\TextWatermarkTemplate();
|
||||
$textWatermarkTemplate->setText("testetst");
|
||||
$textWatermarkTemplate->setGravity('center');
|
||||
$textWatermarkTemplate->setFontsize(30);
|
||||
$result = $cosClient->getObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'ImageHandleParam' => $textWatermarkTemplate->queryString(),
|
||||
'SaveAs' => '/data/exampleobject'
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
|
||||
$local_path = '/data/exampleobject';
|
||||
try {
|
||||
//上传对象,单链接限速
|
||||
$result = $cosClient->putObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'Body' => fopen($local_path, 'rb'),
|
||||
'TrafficLimit' => 8 * 1024 * 1024 // 限制为1MB/s
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
|
||||
//下载对象,单链接限速
|
||||
$result = $cosClient->getObject(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'SaveAs' => $local_path,
|
||||
'TrafficLimit' => 8 * 1024 * 1024 // 限制为1MB/s
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
$local_path = "/data/exampleobject";
|
||||
|
||||
$printbar = function($totalSize, $uploadedSize) {
|
||||
printf("uploaded [%d/%d]\n", $uploadedSize, $totalSize);
|
||||
};
|
||||
|
||||
try {
|
||||
$result = $cosClient->upload(
|
||||
$bucket = 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
$key = 'exampleobject',
|
||||
$body = fopen($local_path, 'rb')
|
||||
/*
|
||||
$options = array(
|
||||
'ACL' => 'string',
|
||||
'CacheControl' => 'string',
|
||||
'ContentDisposition' => 'string',
|
||||
'ContentEncoding' => 'string',
|
||||
'ContentLanguage' => 'string',
|
||||
'ContentLength' => integer,
|
||||
'ContentType' => 'string',
|
||||
'Expires' => 'string',
|
||||
'GrantFullControl' => 'string',
|
||||
'GrantRead' => 'string',
|
||||
'GrantWrite' => 'string',
|
||||
'Metadata' => array(
|
||||
'string' => 'string',
|
||||
),
|
||||
'ContentMD5' => 'string',
|
||||
'ServerSideEncryption' => 'string',
|
||||
'StorageClass' => 'string', //存储类型
|
||||
'Progress' => $printbar, //指定进度条
|
||||
'PartSize' => 10 * 1024 * 1024, //分块大小
|
||||
'Concurrency' => 5 //并发数
|
||||
)
|
||||
*/
|
||||
);
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
require dirname( __FILE__ ) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = 'SECRETID';
|
||||
//'云 API 密钥 SecretId';
|
||||
$secretKey = 'SECRETKEY';
|
||||
//'云 API 密钥 SecretKey';
|
||||
$region = 'ap-beijing';
|
||||
//设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
function uploadfiles( $path, $cosClient ) {
|
||||
foreach ( scandir( $path ) as $afile ) {
|
||||
if ( $afile == '.' || $afile == '..' ) continue;
|
||||
if ( is_dir( $path.'/'.$afile ) ) {
|
||||
uploadfiles( $path.'/'.$afile, $cosClient );
|
||||
} else {
|
||||
$local_file_path = $path.'/'.$afile;
|
||||
$cos_file_path = $local_file_path;
|
||||
// 按照需求自定义拼接上传路径
|
||||
try {
|
||||
$cosClient->upload(
|
||||
$bucket = 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
$key = $cos_file_path,
|
||||
$body = fopen( $cos_file_path, 'rb' )
|
||||
);
|
||||
} catch ( \Exception $e ) {
|
||||
echo( $e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$local_path = '/data/home/folder';
|
||||
uploadfiles( $local_path, $cosClient );
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
require dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
|
||||
$secretId = "SECRETID"; //"云 API 密钥 SecretId";
|
||||
$secretKey = "SECRETKEY"; //"云 API 密钥 SecretKey";
|
||||
$region = "ap-beijing"; //设置一个默认的存储桶地域
|
||||
$cosClient = new Qcloud\Cos\Client(
|
||||
array(
|
||||
'region' => $region,
|
||||
'schema' => 'https', //协议头部,默认为http
|
||||
'credentials'=> array(
|
||||
'secretId' => $secretId ,
|
||||
'secretKey' => $secretKey)));
|
||||
try {
|
||||
$result = $cosClient->uploadPart(array(
|
||||
'Bucket' => 'examplebucket-125000000', //格式:BucketName-APPID
|
||||
'Key' => 'exampleobject',
|
||||
'Body' => 'string',
|
||||
'UploadId' => 'NWNhNDY0YzFfMmZiNTM1MGFfNTM2YV8xYjliMTg',
|
||||
'PartNumber' => 1,
|
||||
'ContentMD5' => 'string',
|
||||
'ContentLength' => 100,
|
||||
));
|
||||
// 请求成功
|
||||
print_r($result);
|
||||
} catch (\Exception $e) {
|
||||
// 请求失败
|
||||
echo($e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user