本文整理匯總了PHP中Common::println方法的典型用法代碼示例。如果您正苦於以下問題:PHP Common::println方法的具體用法?PHP Common::println怎麽用?PHP Common::println使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Common
的用法示例。
在下文中一共展示了Common::println方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: printImage
function printImage($func, $imageFile)
{
$array = getimagesize($imageFile);
Common::println("{$func}, image width: " . $array[0]);
Common::println("{$func}, image height: " . $array[1]);
Common::println("{$func}, image type: " . ($array[2] === 2 ? 'jpg' : 'png'));
Common::println("{$func}, image size: " . ceil(filesize($imageFile)));
}
示例2: exit
use OSS\Core\OssException;
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) {
exit(1);
}
//*******************************簡單使用***************************************************************
/**
* 查看完整用法中的 "putObjectByRawApis"函數,查看使用基礎的分片上傳api進行文件上傳,用戶可以基於這個自行實現斷點續傳等功能
*/
// 使用分片上傳接口上傳文件, 接口會根據文件大小決定是使用普通上傳還是分片上傳
$ossClient->multiuploadFile($bucket, "file.php", __FILE__, array());
Common::println("local file " . __FILE__ . " is uploaded to the bucket {$bucket}, file.php");
// 上傳本地目錄到bucket內的targetdir子目錄中
$ossClient->uploadDir($bucket, "targetdir", __DIR__);
Common::println("local dir " . __DIR__ . " is uploaded to the bucket {$bucket}, targetdir/");
// 列出當前未完成的分片上傳
$listMultipartUploadInfo = $ossClient->listMultipartUploads($bucket, array());
//******************************* 完整用法參考下麵函數 ****************************************************
multiuploadFile($ossClient, $bucket);
putObjectByRawApis($ossClient, $bucket);
uploadDir($ossClient, $bucket);
listMultipartUploads($ossClient, $bucket);
/**
* 通過multipart上傳文件
*
* @param OssClient $ossClient OssClient實例
* @param string $bucket 存儲空間名稱
* @return null
*/
function multiuploadFile($ossClient, $bucket)
示例3: RefererConfig
}
//******************************* 簡單使用 ****************************************************************
//設置referer白名單
$refererConfig = new RefererConfig();
$refererConfig->setAllowEmptyReferer(true);
$refererConfig->addReferer("www.aliiyun.com");
$refererConfig->addReferer("www.aliiyuncs.com");
$ossClient->putBucketReferer($bucket, $refererConfig);
Common::println("bucket {$bucket} refererConfig created:" . $refererConfig->serializeToXml());
//獲取Referer白名單
$refererConfig = $ossClient->getBucketReferer($bucket);
Common::println("bucket {$bucket} refererConfig fetched:" . $refererConfig->serializeToXml());
//刪除referer白名單
$refererConfig = new RefererConfig();
$ossClient->putBucketReferer($bucket, $refererConfig);
Common::println("bucket {$bucket} refererConfig deleted");
//******************************* 完整用法參考下麵函數 ****************************************************
putBucketReferer($ossClient, $bucket);
getBucketReferer($ossClient, $bucket);
deleteBucketReferer($ossClient, $bucket);
getBucketReferer($ossClient, $bucket);
/**
* 設置bucket的防盜鏈配置
*
* @param OssClient $ossClient OssClient實例
* @param string $bucket 存儲空間名稱
* @return null
*/
function putBucketReferer($ossClient, $bucket)
{
$refererConfig = new RefererConfig();
示例4: array
Common::println("ETag: " . $result[1]);
// 判斷object是否存在
$doesExist = $ossClient->doesObjectExist($bucket, "c.file.copy");
Common::println("file c.file.copy exist? " . ($doesExist ? "yes" : "no"));
// 刪除object
$result = $ossClient->deleteObject($bucket, "c.file.copy");
Common::println("c.file.copy is deleted");
Common::println("b.file is created");
Common::println($result['x-oss-request-id']);
// 判斷object是否存在
$doesExist = $ossClient->doesObjectExist($bucket, "c.file.copy");
Common::println("file c.file.copy exist? " . ($doesExist ? "yes" : "no"));
// 批量刪除object
$result = $ossClient->deleteObjects($bucket, array("b.file", "c.file"));
foreach ($result as $object) {
Common::println($object);
}
sleep(2);
unlink("c.file.localcopy");
//******************************* 完整用法參考下麵函數 ****************************************************
listObjects($ossClient, $bucket);
listAllObjects($ossClient, $bucket);
createObjectDir($ossClient, $bucket);
putObject($ossClient, $bucket);
uploadFile($ossClient, $bucket);
getObject($ossClient, $bucket);
getObjectToLocalFile($ossClient, $bucket);
copyObject($ossClient, $bucket);
modifyMetaForObject($ossClient, $bucket);
getObjectMeta($ossClient, $bucket);
deleteObject($ossClient, $bucket);
示例5: LifecycleConfig
}
//******************************* 簡單使用 *******************************************************
//設置lifecycle規則
$lifecycleConfig = new LifecycleConfig();
$actions = array();
$actions[] = new LifecycleAction("Expiration", "Days", 3);
$lifecycleRule = new LifecycleRule("delete obsoleted files", "obsoleted/", "Enabled", $actions);
$lifecycleConfig->addRule($lifecycleRule);
$ossClient->putBucketLifecycle($bucket, $lifecycleConfig);
Common::println("bucket {$bucket} lifecycleConfig created:" . $lifecycleConfig->serializeToXml());
//獲取lifecycle規則
$lifecycleConfig = $ossClient->getBucketLifecycle($bucket);
Common::println("bucket {$bucket} lifecycleConfig fetched:" . $lifecycleConfig->serializeToXml());
//刪除bucket的lifecycle配置
$ossClient->deleteBucketLifecycle($bucket);
Common::println("bucket {$bucket} lifecycleConfig deleted");
//***************************** 完整用法參考下麵函數 ***********************************************
putBucketLifecycle($ossClient, $bucket);
getBucketLifecycle($ossClient, $bucket);
deleteBucketLifecycle($ossClient, $bucket);
getBucketLifecycle($ossClient, $bucket);
/**
* 設置bucket的生命周期配置
*
* @param OssClient $ossClient OssClient實例
* @param string $bucket 存儲空間名稱
* @return null
*/
function putBucketLifecycle($ossClient, $bucket)
{
$lifecycleConfig = new LifecycleConfig();
示例6:
$bucket = Common::getBucketName();
//******************************* 簡單使用 ****************************************************************
//創建bucket
$ossClient->createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
Common::println("bucket {$bucket} created");
// 判斷Bucket是否存在
$doesExist = $ossClient->doesBucketExist($bucket);
Common::println("bucket {$bucket} exist? " . ($doesExist ? "yes" : "no"));
// 獲取Bucket列表
$bucketListInfo = $ossClient->listBuckets();
// 設置bucket的ACL
$ossClient->putBucketAcl($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
Common::println("bucket {$bucket} acl put");
// 獲取bucket的ACL
$acl = $ossClient->getBucketAcl($bucket);
Common::println("bucket {$bucket} acl get: " . $acl);
//******************************* 完整用法參考下麵函數 ****************************************************
createBucket($ossClient, $bucket);
doesBucketExist($ossClient, $bucket);
deleteBucket($ossClient, $bucket);
putBucketAcl($ossClient, $bucket);
getBucketAcl($ossClient, $bucket);
listBuckets($ossClient);
/**
* 創建一個存儲空間
* acl 指的是bucket的訪問控製權限,有三種,私有讀寫,公共讀私有寫,公共讀寫。
* 私有讀寫就是隻有bucket的擁有者或授權用戶才有權限操作
* 三種權限分別對應 (OssClient::OSS_ACL_TYPE_PRIVATE,OssClient::OSS_ACL_TYPE_PUBLIC_READ, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE)
*
* @param OssClient $ossClient OssClient實例
* @param string $bucket 要創建的存儲空間名稱
示例7: array
Common::println("b.file is fetched to the local file: c.file.localcopy");
// 拷貝object
$ossClient->copyObject($bucket, "c.file", $bucket, "c.file.copy");
Common::println("c.file is copied to c.file.copy");
// 判斷object是否存在
$doesExist = $ossClient->doesObjectExist($bucket, "c.file.copy");
Common::println("file c.file.copy exist? " . ($doesExist ? "yes" : "no"));
// 刪除object
$ossClient->deleteObject($bucket, "c.file.copy");
Common::println("c.file.copy is deleted");
// 判斷object是否存在
$doesExist = $ossClient->doesObjectExist($bucket, "c.file.copy");
Common::println("file c.file.copy exist? " . ($doesExist ? "yes" : "no"));
// 批量刪除object
$ossClient->deleteObjects($bucket, array("b.file", "c.file"));
Common::println("b.file, c.file are deleted");
sleep(2);
unlink("c.file.localcopy");
//******************************* 完整用法參考下麵函數 ****************************************************
listObjects($ossClient, $bucket);
listAllObjects($ossClient, $bucket);
createObjectDir($ossClient, $bucket);
putObject($ossClient, $bucket);
uploadFile($ossClient, $bucket);
getObject($ossClient, $bucket);
getObjectToLocalFile($ossClient, $bucket);
copyObject($ossClient, $bucket);
modifyMetaForObject($ossClient, $bucket);
getObjectMeta($ossClient, $bucket);
deleteObject($ossClient, $bucket);
deleteObjects($ossClient, $bucket);
示例8: exit
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) {
exit(1);
}
//*******************************簡單使用***************************************************************
// 設置Bucket的靜態網站托管模式
$websiteConfig = new WebsiteConfig("index.html", "error.html");
$ossClient->putBucketWebsite($bucket, $websiteConfig);
Common::println("bucket {$bucket} websiteConfig created:" . $websiteConfig->serializeToXml());
// 查看Bucket的靜態網站托管狀態
$websiteConfig = $ossClient->getBucketWebsite($bucket);
Common::println("bucket {$bucket} websiteConfig fetched:" . $websiteConfig->serializeToXml());
// 刪除Bucket的靜態網站托管模式
$ossClient->deleteBucketWebsite($bucket);
Common::println("bucket {$bucket} websiteConfig deleted");
//******************************* 完整用法參考下麵函數 ****************************************************
putBucketWebsite($ossClient, $bucket);
getBucketWebsite($ossClient, $bucket);
deleteBucketWebsite($ossClient, $bucket);
getBucketWebsite($ossClient, $bucket);
/**
* 設置bucket的靜態網站托管模式配置
*
* @param $ossClient OssClient
* @param $bucket string 存儲空間名稱
* @return null
*/
function putBucketWebsite($ossClient, $bucket)
{
$websiteConfig = new WebsiteConfig("index.html", "error.html");
示例9: CorsConfig
// 設置cors配置
$corsConfig = new CorsConfig();
$rule = new CorsRule();
$rule->addAllowedHeader("x-oss-header");
$rule->addAllowedOrigin("http://www.b.com");
$rule->addAllowedMethod("POST");
$rule->setMaxAgeSeconds(10);
$corsConfig->addRule($rule);
$ossClient->putBucketCors($bucket, $corsConfig);
Common::println("bucket {$bucket} corsConfig created:" . $corsConfig->serializeToXml());
// 獲取cors配置
$corsConfig = $ossClient->getBucketCors($bucket);
Common::println("bucket {$bucket} corsConfig fetched:" . $corsConfig->serializeToXml());
// 刪除cors配置
$ossClient->deleteBucketCors($bucket);
Common::println("bucket {$bucket} corsConfig deleted");
//******************************* 完整用法參考下麵函數 *****************************************************
putBucketCors($ossClient, $bucket);
getBucketCors($ossClient, $bucket);
deleteBucketCors($ossClient, $bucket);
getBucketCors($ossClient, $bucket);
/**
* 設置bucket的cors配置
*
* @param OssClient $ossClient OssClient實例
* @param string $bucket 存儲空間名稱
* @return null
*/
function putBucketCors($ossClient, $bucket)
{
$corsConfig = new CorsConfig();
示例10: file_get_contents
$copiedObject = "multipart-callback-test.txt.copied";
$ossClient->putObject($bucket, $copiedObject, file_get_contents(__FILE__));
/**
* step 1. 初始化一個分塊上傳事件, 也就是初始化上傳Multipart, 獲取upload id
*/
$upload_id = $ossClient->initiateMultipartUpload($bucket, $object);
/**
* step 2. uploadPartCopy
*/
$copyId = 1;
$eTag = $ossClient->uploadPartCopy($bucket, $copiedObject, $bucket, $object, $copyId, $upload_id);
$upload_parts[] = array('PartNumber' => $copyId, 'ETag' => $eTag);
$listPartsInfo = $ossClient->listParts($bucket, $object, $upload_id);
/**
* step 3.
*/
$json = '{
"callbackUrl":"callback.oss-demo.com:23450",
"callbackHost":"oss-cn-hangzhou.aliyuncs.com",
"callbackBody":"{\\"mimeType\\":${mimeType},\\"size\\":${size},\\"x:var1\\":${x:var1},\\"x:var2\\":${x:var2}}",
"callbackBodyType":"application/json"
}';
$var = '{
"x:var1":"value1",
"x:var2":"值2"
}';
$options = array(OssClient::OSS_CALLBACK => $json, OssClient::OSS_CALLBACK_VAR => $var);
$result = $ossClient->completeMultipartUpload($bucket, $object, $upload_id, $upload_parts, $options);
Common::println($result['body']);
Common::println($result['info']['http_code']);
示例11: exit
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) {
exit(1);
}
//******************************* 簡單使用 ***************************************************************
$ossClient->uploadFile($bucket, "a.file", __FILE__);
// 生成GetObject的簽名url,用戶可以使用這個url直接在瀏覽器下載
$signedUrl = $ossClient->signUrl($bucket, "a.file", 3600);
Common::println($signedUrl);
// 生成用於putObject的簽名URL,用戶可以直接用put方法使用這個url上傳文件到 "a.file"
$signedUrl = $ossClient->signUrl($bucket, "a.file", "3600", "PUT");
Common::println($signedUrl);
// 生成從本地文件上傳PutObject的簽名url, 用戶可以直接使用這個url把本地文件上傳到 "a.file"
$signedUrl = $ossClient->signUrl($bucket, "a.file", 3600, "PUT", array('Content-Type' => 'txt'));
Common::println($signedUrl);
//******************************* 完整用法參考下麵函數 ****************************************************
getSignedUrlForPuttingObject($ossClient, $bucket);
getSignedUrlForPuttingObjectFromFile($ossClient, $bucket);
getSignedUrlForGettingObject($ossClient, $bucket);
/**
* 生成GetObject的簽名url,主要用於私有權限下的讀訪問控製
*
* @param $ossClient OssClient OssClient實例
* @param $bucket string 存儲空間名稱
* @return null
*/
function getSignedUrlForGettingObject($ossClient, $bucket)
{
$object = "test/test-signature-test-upload-and-download.txt";
$timeout = 3600;
示例12: foreach
創建好直播頻道之後調用getLiveChannelInfo可以得到頻道相關的信息
*/
$info = $ossClient->getLiveChannelInfo($bucket, 'test_rtmp_live');
Common::println("bucket {$bucket} LiveChannelInfo:\n" . "live channel info description: " . $info->getDescription() . "\n" . "live channel info status: " . $info->getStatus() . "\n" . "live channel info type: " . $info->getType() . "\n" . "live channel info fragDuration: " . $info->getFragDuration() . "\n" . "live channel info fragCount: " . $info->getFragCount() . "\n" . "live channel info playListName: " . $info->getPlayListName() . "\n");
/**
如果想查看一個頻道曆史推流記錄,可以調用getLiveChannelHistory。目前最多可以看到10次推流的記錄
*/
$history = $ossClient->getLiveChannelHistory($bucket, "test_rtmp_live");
if (count($history->getLiveRecordList()) != 0) {
foreach ($history->getLiveRecordList() as $recordList) {
Common::println("bucket {$bucket} liveChannelHistory:\n" . "live channel history startTime: " . $recordList->getStartTime() . "\n" . "live channel history endTime: " . $recordList->getEndTime() . "\n" . "live channel history remoteAddr: " . $recordList->getRemoteAddr() . "\n");
}
}
/**
對於正在推流的頻道調用get_live_channel_stat可以獲得流的狀態信息。
如果頻道正在推流,那麽stat_result中的所有字段都有意義。
如果頻道閑置或者處於“Disabled”狀態,那麽status為“Idle”或“Disabled”,其他字段無意義。
*/
$status = $ossClient->getLiveChannelStatus($bucket, "test_rtmp_live");
Common::println("bucket {$bucket} listLiveChannel:\n" . "live channel status status: " . $status->getStatus() . "\n" . "live channel status ConnectedTime: " . $status->getConnectedTime() . "\n" . "live channel status VideoWidth: " . $status->getVideoWidth() . "\n" . "live channel status VideoHeight: " . $status->getVideoHeight() . "\n" . "live channel status VideoFrameRate: " . $status->getVideoFrameRate() . "\n" . "live channel status VideoBandwidth: " . $status->getVideoBandwidth() . "\n" . "live channel status VideoCodec: " . $status->getVideoCodec() . "\n" . "live channel status AudioBandwidth: " . $status->getAudioBandwidth() . "\n" . "live channel status AudioSampleRate: " . $status->getAudioSampleRate() . "\n" . "live channel status AdioCodec: " . $status->getAudioCodec() . "\n");
/**
* 如果希望利用直播推流產生的ts文件生成一個點播列表,可以使用postVodPlaylist方法。
* 指定起始時間為當前時間減去60秒,結束時間為當前時間,這意味著將生成一個長度為60秒的點播視頻。
* 播放列表指定為“vod_playlist.m3u8”,也就是說這個接口調用成功之後會在OSS上生成一個名叫“vod_playlist.m3u8”的播放列表文件。
*/
$current_time = time();
$ossClient->postVodPlaylist($bucket, "test_rtmp_live", "vod_playlist.m3u8", array('StartTime' => $current_time - 60, 'EndTime' => $current_time));
/**
* 如果一個直播頻道已經不打算再使用了,那麽可以調用delete_live_channel來刪除頻道。
*/
$ossClient->deleteBucketLiveChannel($bucket, "test_rtmp_live");