123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace Qcloud\Cos;
- function region_map($region)
- {
- $regionmap = array(
- 'cn-east' => 'ap-shanghai',
- 'cn-south' => 'ap-guangzhou',
- 'cn-north' => 'ap-beijing-1',
- 'cn-south-2' => 'ap-guangzhou-2',
- 'cn-southwest' => 'ap-chengdu',
- 'sg' => 'ap-singapore',
- 'tj' => 'ap-beijing-1',
- 'bj' => 'ap-beijing',
- 'sh' => 'ap-shanghai',
- 'gz' => 'ap-guangzhou',
- 'cd' => 'ap-chengdu',
- 'sgp' => 'ap-singapore'
- );
- if (isset($regionmap[$region])) {
- return $regionmap[$region];
- }
- return $region;
- }
- function encodeKey($key)
- {
- return str_replace('%2F', '/', rawurlencode($key));
- }
- function endWith($haystack, $needle)
- {
- $length = strlen($needle);
- if ($length == 0) {
- return true;
- }
- return (substr($haystack, -$length) === $needle);
- }
- function startWith($haystack, $needle)
- {
- $length = strlen($needle);
- if ($length == 0) {
- return true;
- }
- return (substr($haystack, 0, $length) === $needle);
- }
- function headersMap($command, $request)
- {
- $headermap = array(
- 'TransferEncoding' => 'Transfer-Encoding',
- 'ChannelId' => 'x-cos-channel-id'
- );
- foreach ($headermap as $key => $value) {
- if (isset($command[$key])) {
- $request = $request->withHeader($value, $command[$key]);
- }
- }
- return $request;
- }
- if (!function_exists('str_contains')) {
- function str_contains($haystack, $needle)
- {
- return strpos($haystack, $needle) !== false;
- }
- }
|