From efb6c5a756b108fc6e59327edaf41251607e7f60 Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Wed, 6 Mar 2024 16:52:43 +0800 Subject: [PATCH] fixed --- app/common/logic/RemoteRequestLogic.php | 2 +- ...EnvironmentVariableCredentialsProvider.php | 20 + .../oss-sdk-php/src/OSS/Model/Owner.php | 46 + .../src/OSS/Signer/SignerInterface.php | 12 + .../oss-sdk-php/src/OSS/Signer/SignerV1.php | 161 ++ .../oss-sdk-php/src/OSS/Signer/SignerV4.php | 244 +++ .../tests/OSS/Tests/AssumeRole.php | 32 + .../Tests/OssClientAsyncProcessObjectTest.php | 68 + .../OSS/Tests/OssClientForcePathStyleTest.php | 50 + .../OSS/Tests/OssClientPresignV4Test.php | 326 ++++ .../OSS/Tests/OssClientSignatureV4Test.php | 1409 +++++++++++++++++ .../tests/OSS/Tests/SignerTest.php | 558 +++++++ .../oss-sdk-php/tests/OSS/Tests/StsBase.php | 33 + .../oss-sdk-php/tests/OSS/Tests/StsClient.php | 108 ++ vendor/bin/jp.php | 119 ++ vendor/bin/jp.php.bat | 5 + vendor/mtdowling/jmespath.php/bin/jp.php | 74 + vendor/mtdowling/jmespath.php/bin/perf.php | 68 + vendor/myclabs/php-enum/stubs/Stringable.php | 11 + .../phpspreadsheet/phpunit10.xml.dist | 15 + .../src/PhpSpreadsheet/Cell/IgnoredErrors.php | 66 + .../src/PhpSpreadsheet/Chart/AxisText.php | 56 + .../src/PhpSpreadsheet/Helper/Downloader.php | 89 ++ .../src/PhpSpreadsheet/Helper/Handler.php | 46 + .../Reader/Xlsx/SharedFormula.php | 26 + .../Reader/Xml/DataValidations.php | 177 +++ .../Style/NumberFormat/Wizard/Date.php | 125 ++ .../Style/NumberFormat/Wizard/DateTime.php | 50 + .../NumberFormat/Wizard/DateTimeWizard.php | 44 + .../Style/NumberFormat/Wizard/Duration.php | 153 ++ .../Style/NumberFormat/Wizard/Time.php | 105 ++ .../src/PhpSpreadsheet/Style/RgbTint.php | 175 ++ .../src/PhpSpreadsheet/Theme.php | 269 ++++ .../src/PhpSpreadsheet/Writer/ZipStream0.php | 17 + .../src/PhpSpreadsheet/Writer/ZipStream2.php | 21 + .../src/PhpSpreadsheet/Writer/ZipStream3.php | 22 + .../sample/aIBodyRecognitionProcess.php | 38 + .../cos-sdk-v5/sample/aIGameRecProcess.php | 38 + .../sample/aIImageColoringProcess.php | 65 + .../cos-sdk-v5/sample/aIImageCropProcess.php | 83 + .../sample/aIImageEnhanceProcess.php | 79 + .../sample/aIImageSuperResolutionProcess.php | 65 + .../cos-sdk-v5/sample/aILicenseRecProcess.php | 40 + .../sample/autoTranslationBlockProcess.php | 29 + .../cos-sdk-v5/sample/closeAiService.php | 24 + .../cos-sdk-v5/sample/closeAsrService.php | 24 + .../cos-sdk-v5/sample/closeImageSlim.php | 23 + .../sample/createAiTranslationJobs.php | 54 + .../sample/createAiWordsGeneralizeJobs.php | 45 + .../sample/createM3U8PlayListJobs.php | 45 + .../createMediaNoiseReductionTemplate.php | 31 + .../createMediaSegmentVideoBodyJobs.php | 90 ++ .../sample/createMediaSmartCoverTemplate.php | 34 + .../sample/createMediaTargetRecJobs.php | 74 + .../sample/createMediaTargetRecTemplate.php | 32 + .../createMediaTranscodeProTemplate.php | 61 + .../sample/createMediaVideoEnhanceJobs.php | 201 +++ .../createMediaVideoEnhanceTemplate.php | 65 + .../sample/createVoiceSoundHoundJobs.php | 41 + .../createVoiceSpeechRecognitionJobs.php | 95 ++ .../createVoiceSpeechRecognitionTemplate.php | 44 + .../cos-sdk-v5/sample/createVoiceTtsJobs.php | 86 + .../sample/createVoiceTtsTemplate.php | 33 + .../sample/createVoiceVocalScoreJobs.php | 44 + .../cos-sdk-v5/sample/detectLabelProcess.php | 40 + .../cos-sdk-v5/sample/detectPetProcess.php | 38 + .../cos-sdk-v5/sample/getAiBucketList.php | 30 + .../cos-sdk-v5/sample/getAiQueueList.php | 28 + .../cos-sdk-v5/sample/getAsrBucketList.php | 30 + .../cos-sdk-v5/sample/getAsrQueueList.php | 28 + .../qcloud/cos-sdk-v5/sample/getImageSlim.php | 23 + .../cos-sdk-v5/sample/getPicBucketList.php | 30 + .../cos-sdk-v5/sample/getPicQueueList.php | 28 + .../cos-sdk-v5/sample/goodsMattingProcess.php | 67 + .../sample/livenessRecognitionProcess.php | 20 + .../cos-sdk-v5/sample/openAiService.php | 24 + .../cos-sdk-v5/sample/openAsrService.php | 24 + .../cos-sdk-v5/sample/openImageSlim.php | 30 + .../sample/recognizeLogoProcess.php | 38 + vendor/qcloud/cos-sdk-v5/sample/sts_demo.php | 102 ++ .../cos-sdk-v5/sample/updateAiQueue.php | 38 + .../cos-sdk-v5/sample/updateAsrQueue.php | 38 + .../updateMediaNoiseReductionTemplate.php | 32 + .../sample/updateMediaSmartCoverTemplate.php | 35 + .../sample/updateMediaTargetRecTemplate.php | 33 + .../updateMediaTranscodeProTemplate.php | 62 + .../updateMediaVideoEnhanceTemplate.php | 66 + .../cos-sdk-v5/sample/updatePicQueue.php | 38 + .../updateVoiceSpeechRecognitionTemplate.php | 45 + .../sample/updateVoiceTtsTemplate.php | 34 + .../Resources/unidata/caseFolding.php | 119 ++ .../Resources/stubs/CURLStringFile.php | 51 + .../ValueResolverInterface.php | 26 + .../framework/src/think/console/bin/README.md | 1 + .../src/think/console/bin/hiddeninput.exe | Bin 0 -> 9216 bytes .../src/think/route/ResourceRegister.php | 72 + vendor/w7corp/easywechat/docs/.npmrc | 1 + .../w7corp/easywechat/docs/src/4.x/client.md | 44 + .../docs/src/5.x/mini-program/shipping.md | 117 ++ .../easywechat/docs/src/6.x/pay/media.md | 32 + .../src/Kernel/Contracts/JsApiTicket.php | 15 + .../Contracts/RefreshableJsApiTicket.php | 8 + .../Kernel/HttpClient/ScopingHttpClient.php | 62 + .../easywechat/src/OpenWork/JsApiTicket.php | 165 ++ .../src/Pay/Contracts/Validator.php | 15 + .../Exceptions/InvalidSignatureException.php | 9 + .../w7corp/easywechat/src/Pay/Validator.php | 71 + 107 files changed, 8193 insertions(+), 1 deletion(-) create mode 100644 vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/EnvironmentVariableCredentialsProvider.php create mode 100644 vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Owner.php create mode 100644 vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerInterface.php create mode 100644 vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV1.php create mode 100644 vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV4.php create mode 100644 vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AssumeRole.php create mode 100644 vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientAsyncProcessObjectTest.php create mode 100644 vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientForcePathStyleTest.php create mode 100644 vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignV4Test.php create mode 100644 vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureV4Test.php create mode 100644 vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SignerTest.php create mode 100644 vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsBase.php create mode 100644 vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsClient.php create mode 100644 vendor/bin/jp.php create mode 100644 vendor/bin/jp.php.bat create mode 100644 vendor/mtdowling/jmespath.php/bin/jp.php create mode 100644 vendor/mtdowling/jmespath.php/bin/perf.php create mode 100644 vendor/myclabs/php-enum/stubs/Stringable.php create mode 100644 vendor/phpoffice/phpspreadsheet/phpunit10.xml.dist create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IgnoredErrors.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/AxisText.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Downloader.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Handler.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/SharedFormula.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/DataValidations.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Date.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTimeWizard.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Duration.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Time.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/RgbTint.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Theme.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream0.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream2.php create mode 100644 vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream3.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/aIBodyRecognitionProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/aIGameRecProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/aIImageColoringProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/aIImageCropProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/aIImageEnhanceProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/aIImageSuperResolutionProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/aILicenseRecProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/autoTranslationBlockProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/closeAiService.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/closeAsrService.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/closeImageSlim.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createAiTranslationJobs.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createAiWordsGeneralizeJobs.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createM3U8PlayListJobs.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createMediaNoiseReductionTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createMediaSegmentVideoBodyJobs.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createMediaSmartCoverTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createMediaTargetRecJobs.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createMediaTargetRecTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createMediaTranscodeProTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createMediaVideoEnhanceJobs.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createMediaVideoEnhanceTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createVoiceSoundHoundJobs.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createVoiceSpeechRecognitionJobs.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createVoiceSpeechRecognitionTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createVoiceTtsJobs.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createVoiceTtsTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/createVoiceVocalScoreJobs.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/detectLabelProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/detectPetProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/getAiBucketList.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/getAiQueueList.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/getAsrBucketList.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/getAsrQueueList.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/getImageSlim.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/getPicBucketList.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/getPicQueueList.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/goodsMattingProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/livenessRecognitionProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/openAiService.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/openAsrService.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/openImageSlim.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/recognizeLogoProcess.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/sts_demo.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/updateAiQueue.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/updateAsrQueue.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/updateMediaNoiseReductionTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/updateMediaSmartCoverTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/updateMediaTargetRecTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/updateMediaTranscodeProTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/updateMediaVideoEnhanceTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/updatePicQueue.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/updateVoiceSpeechRecognitionTemplate.php create mode 100644 vendor/qcloud/cos-sdk-v5/sample/updateVoiceTtsTemplate.php create mode 100644 vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php create mode 100644 vendor/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php create mode 100644 vendor/symfony/psr-http-message-bridge/ArgumentValueResolver/ValueResolverInterface.php create mode 100644 vendor/topthink/framework/src/think/console/bin/README.md create mode 100644 vendor/topthink/framework/src/think/console/bin/hiddeninput.exe create mode 100644 vendor/topthink/framework/src/think/route/ResourceRegister.php create mode 100644 vendor/w7corp/easywechat/docs/.npmrc create mode 100644 vendor/w7corp/easywechat/docs/src/4.x/client.md create mode 100644 vendor/w7corp/easywechat/docs/src/5.x/mini-program/shipping.md create mode 100644 vendor/w7corp/easywechat/docs/src/6.x/pay/media.md create mode 100644 vendor/w7corp/easywechat/src/Kernel/Contracts/JsApiTicket.php create mode 100644 vendor/w7corp/easywechat/src/Kernel/Contracts/RefreshableJsApiTicket.php create mode 100644 vendor/w7corp/easywechat/src/Kernel/HttpClient/ScopingHttpClient.php create mode 100644 vendor/w7corp/easywechat/src/OpenWork/JsApiTicket.php create mode 100644 vendor/w7corp/easywechat/src/Pay/Contracts/Validator.php create mode 100644 vendor/w7corp/easywechat/src/Pay/Exceptions/InvalidSignatureException.php create mode 100644 vendor/w7corp/easywechat/src/Pay/Validator.php diff --git a/app/common/logic/RemoteRequestLogic.php b/app/common/logic/RemoteRequestLogic.php index 8435e1e..758219c 100644 --- a/app/common/logic/RemoteRequestLogic.php +++ b/app/common/logic/RemoteRequestLogic.php @@ -181,7 +181,7 @@ class RemoteRequestLogic extends BaseLogic if (!empty($ambientTemperatureDevice)) { $rangeData = self::requestRangeMonitorData($ambientTemperatureDevice); if (!empty($rangeData)) { - $ambientTemperatureDevice['RangeMonitorData'] = $rangeData[0]; + $ambientTemperatureDevice['RangeMonitorData'] = $rangeData[1]; } else { $ambientTemperatureDevice['RangeMonitorData'] = [0,0,0,0,0,0,0]; } diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/EnvironmentVariableCredentialsProvider.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/EnvironmentVariableCredentialsProvider.php new file mode 100644 index 0000000..a5df615 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/EnvironmentVariableCredentialsProvider.php @@ -0,0 +1,20 @@ +id = $id; + $this->displayName = $displayName; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getDisplayName() + { + return $this->displayName; + } + + private $id; + private $displayName; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerInterface.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerInterface.php new file mode 100644 index 0000000..c592a4f --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerInterface.php @@ -0,0 +1,12 @@ +request_headers['Date'])) { + $request->add_header('Date', gmdate('D, d M Y H:i:s \G\M\T')); + } + // Credentials information + if (!empty($credentials->getSecurityToken())) { + $request->add_header("x-oss-security-token", $credentials->getSecurityToken()); + } + $headers = $request->request_headers; + $method = strtoupper($request->method); + $date = $headers['Date']; + $resourcePath = $this->getResourcePath($options); + $queryString = parse_url($request->request_url, PHP_URL_QUERY); + $query = array(); + if ($queryString !== null) { + parse_str($queryString, $query); + } + $stringToSign = $this->calcStringToSign($method, $date, $headers, $resourcePath, $query); +// printf("sign str:%s" . PHP_EOL, $stringToSign); + $options['string_to_sign'] = $stringToSign; + $signature = base64_encode(hash_hmac('sha1', $stringToSign, $credentials->getAccessKeySecret(), true)); + $request->add_header('Authorization', 'OSS ' . $credentials->getAccessKeyId() . ':' . $signature); + } + + public function presign(RequestCore $request, Credentials $credentials, array &$options) + { + $headers = $request->request_headers; + // Date + $expiration = $options['expiration']; + if (!isset($request->request_headers['Date'])) { + $request->add_header('Date', gmdate('D, d M Y H:i:s \G\M\T')); + } + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + if ($queryString !== null) { + parse_str($queryString, $query); + } + // Credentials information + if (!empty($credentials->getSecurityToken())) { + $query["security-token"] = $credentials->getSecurityToken(); + } + $method = strtoupper($request->method); + $date = $expiration . ""; + $resourcePath = $this->getResourcePath($options); + $stringToSign = $this->calcStringToSign($method, $date, $headers, $resourcePath, $query); + $options['string_to_sign'] = $stringToSign; + $signature = base64_encode(hash_hmac('sha1', $stringToSign, $credentials->getAccessKeySecret(), true)); + $query['OSSAccessKeyId'] = $credentials->getAccessKeyId(); + $query['Expires'] = $date; + $query['Signature'] = $signature; + $queryString = OssUtil::toQueryString($query); + $parsed_url['query'] = $queryString; + $request->request_url = OssUtil::unparseUrl($parsed_url); + } + + private function getResourcePath(array $options) + { + $resourcePath = '/'; + if (strlen($options['bucket']) > 0) { + $resourcePath .= $options['bucket'] . '/'; + } + if (strlen($options['key']) > 0) { + $resourcePath .= $options['key']; + } + return $resourcePath; + } + + private function calcStringToSign($method, $date, array $headers, $resourcePath, array $query) + { + /* + SignToString = + VERB + "\n" + + Content-MD5 + "\n" + + Content-Type + "\n" + + Date + "\n" + + CanonicalizedOSSHeaders + + CanonicalizedResource + Signature = base64(hmac-sha1(AccessKeySecret, SignToString)) + */ + $contentMd5 = ''; + $contentType = ''; + // CanonicalizedOSSHeaders + $signheaders = array(); + foreach ($headers as $key => $value) { + $lowk = strtolower($key); + if (strncmp($lowk, "x-oss-", 6) == 0) { + $signheaders[$lowk] = $value; + } else if ($lowk === 'content-md5') { + $contentMd5 = $value; + } else if ($lowk === 'content-type') { + $contentType = $value; + } + } + ksort($signheaders); + $canonicalizedOSSHeaders = ''; + foreach ($signheaders as $key => $value) { + $canonicalizedOSSHeaders .= $key . ':' . $value . "\n"; + } + // CanonicalizedResource + $signquery = array(); + foreach ($query as $key => $value) { + if (in_array($key, $this->signKeyList)) { + $signquery[$key] = $value; + } + } + ksort($signquery); + $sortedQueryList = array(); + foreach ($signquery as $key => $value) { + if (strlen($value) > 0) { + $sortedQueryList[] = $key . '=' . $value; + } else { + $sortedQueryList[] = $key; + } + } + $queryStringSorted = implode('&', $sortedQueryList); + $canonicalizedResource = $resourcePath; + if (!empty($queryStringSorted)) { + $canonicalizedResource .= '?' . $queryStringSorted; + } + return $method . "\n" . $contentMd5 . "\n" . $contentType . "\n" . $date . "\n" . $canonicalizedOSSHeaders . $canonicalizedResource; + } + + private $signKeyList = array( + "acl", "uploads", "location", "cors", + "logging", "website", "referer", "lifecycle", + "delete", "append", "tagging", "objectMeta", + "uploadId", "partNumber", "security-token", "x-oss-security-token", + "position", "img", "style", "styleName", + "replication", "replicationProgress", + "replicationLocation", "cname", "bucketInfo", + "comp", "qos", "live", "status", "vod", + "startTime", "endTime", "symlink", + "x-oss-process", "response-content-type", "x-oss-traffic-limit", + "response-content-language", "response-expires", + "response-cache-control", "response-content-disposition", + "response-content-encoding", "udf", "udfName", "udfImage", + "udfId", "udfImageDesc", "udfApplication", + "udfApplicationLog", "restore", "callback", "callback-var", "qosInfo", + "policy", "stat", "encryption", "versions", "versioning", "versionId", "requestPayment", + "x-oss-request-payer", "sequential", + "inventory", "inventoryId", "continuation-token", "asyncFetch", + "worm", "wormId", "wormExtend", "withHashContext", + "x-oss-enable-md5", "x-oss-enable-sha1", "x-oss-enable-sha256", + "x-oss-hash-ctx", "x-oss-md5-ctx", "transferAcceleration", + "regionList", "cloudboxes", "x-oss-ac-source-ip", "x-oss-ac-subnet-mask", "x-oss-ac-vpc-id", "x-oss-ac-forward-allow", + "metaQuery", "resourceGroup", "rtc", "x-oss-async-process", "responseHeader" + ); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV4.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV4.php new file mode 100644 index 0000000..039b04a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV4.php @@ -0,0 +1,244 @@ +request_headers['Date'])) { + $request->add_header('Date', gmdate('D, d M Y H:i:s \G\M\T')); + } + $timestamp = strtotime($request->request_headers['Date']); + if ($timestamp === false) { + $timestamp = time(); + } + $datetime = gmdate('Ymd\THis\Z', $timestamp); + $date = substr($datetime, 0, 8); + $request->add_header("x-oss-date", $datetime); + if (!isset($request->request_headers['x-oss-content-sha256'])) { + $request->add_header("x-oss-content-sha256", 'UNSIGNED-PAYLOAD'); + } + // Credentials information + if (!empty($credentials->getSecurityToken())) { + $request->add_header("x-oss-security-token", $credentials->getSecurityToken()); + } + $headers = $request->request_headers; + $method = strtoupper($request->method); + $region = $options['region']; + $product = $options['product']; + $scope = $this->buildScope($date, $region, $product); + $resourcePath = $this->getResourcePath($options); + $additionalHeaders = $this->getCommonAdditionalHeaders($request, $options); + $queryString = parse_url($request->request_url, PHP_URL_QUERY); + $query = array(); + if ($queryString !== null) { + parse_str($queryString, $query); + } + $canonicalRequest = $this->calcCanonicalRequest($method, $resourcePath, $query, $headers, $additionalHeaders); + $stringToSign = $this->calcStringToSign($datetime, $scope, $canonicalRequest); +// printf('canonical request:%s' . PHP_EOL, $canonicalRequest); +// printf('sign str:%s' . PHP_EOL, $stringToSign); + $options['string_to_sign'] = $stringToSign; + $signature = $this->calcSignature($credentials->getAccessKeySecret(), $date, $region, $product, $stringToSign); + $authorization = 'OSS4-HMAC-SHA256 Credential=' . $credentials->getAccessKeyId() . '/' . $scope; + $additionalHeadersString = implode(';', $additionalHeaders); + if ($additionalHeadersString !== '') { + $authorization .= ',AdditionalHeaders=' . $additionalHeadersString; + } + $authorization .= ',Signature=' . $signature; + $request->add_header('Authorization', $authorization); + } + + public function presign(RequestCore $request, Credentials $credentials, array &$options) + { + if (!isset($request->request_headers['Date'])) { + $request->add_header('Date', gmdate('D, d M Y H:i:s \G\M\T')); + } + $timestamp = strtotime($request->request_headers['Date']); + if ($timestamp === false) { + $timestamp = time(); + } + $datetime = gmdate('Ymd\THis\Z', $timestamp); + $expiration = $options['expiration']; + $date = substr($datetime, 0, 8); + $expires = $expiration - $timestamp; + $headers = $request->request_headers; + $method = strtoupper($request->method); + $region = $options['region']; + $product = $options['product']; + $scope = $this->buildScope($date, $region, $product); + $resourcePath = $this->getResourcePath($options); + $additionalHeaders = $this->getCommonAdditionalHeaders($request, $options); + $queryString = parse_url($request->request_url, PHP_URL_QUERY); + $query = array(); + if ($queryString !== null) { + parse_str($queryString, $query); + } + if (!empty($credentials->getSecurityToken())) { + $query["x-oss-security-token"] = $credentials->getSecurityToken(); + } + $query["x-oss-signature-version"] = 'OSS4-HMAC-SHA256'; + $query["x-oss-date"] = $datetime; + $query["x-oss-expires"] = $expires; + $query["x-oss-credential"] = $credentials->getAccessKeyId() . '/' . $scope; + if (count($additionalHeaders) > 0) { + $query["x-oss-additional-headers"] = implode(";", $additionalHeaders); + } + $canonicalRequest = $this->calcCanonicalRequest($method, $resourcePath, $query, $headers, $additionalHeaders); + $stringToSign = $this->calcStringToSign($datetime, $scope, $canonicalRequest); +// printf('canonical request:%s' . PHP_EOL, $canonicalRequest); +// printf('sign str:%s' . PHP_EOL, $stringToSign); + $options['string_to_sign'] = $stringToSign; + $signature = $this->calcSignature($credentials->getAccessKeySecret(), $date, $region, $product, $stringToSign); + $query["x-oss-signature"] = $signature; + $queryStr = OssUtil::toQueryString($query); + $explodeUrl = explode('?', $request->request_url); + $index = count($explodeUrl); + if ($index === 1) { + $request->request_url .= '?' . $queryStr; + } else { + $baseUrl = $explodeUrl[0]; + $request->request_url = $baseUrl . '?' . $queryStr; + } + } + + private function getResourcePath(array $options) + { + $resourcePath = '/'; + if (strlen($options['bucket']) > 0) { + $resourcePath .= $options['bucket'] . '/'; + } + if (strlen($options['key']) > 0) { + $resourcePath .= $options['key']; + } + return $resourcePath; + } + + private function getCommonAdditionalHeaders(RequestCore $request, array $options) + { + if (isset($options[OssClient::OSS_ADDITIONAL_HEADERS])) { + $addHeaders = array(); + foreach ($options[OssClient::OSS_ADDITIONAL_HEADERS] as $key) { + $lowk = strtolower($key); + if ($this->isDefaultSignedHeader($lowk)) { + continue; + } + $addHeaders[$lowk] = ''; + } + $headers = array(); + foreach ($request->request_headers as $key => $value) { + $lowk = strtolower($key); + if (isset($addHeaders[$lowk])) { + $headers[$lowk] = ''; + } + } + ksort($headers); + return array_keys($headers); + } + return array(); + } + + private function isDefaultSignedHeader($low) + { + if (strncmp($low, "x-oss-", 6) == 0 || + $low === "content-type" || + $low === "content-md5") { + return true; + } + return false; + } + + private function calcStringToSign($datetime, $scope, $canonicalRequest) + { + /* + StringToSign + "OSS4-HMAC-SHA256" + "\n" + + TimeStamp + "\n" + + Scope + "\n" + + Hex(SHA256Hash(Canonical Request)) + */ + $hashedRequest = hash('sha256', $canonicalRequest); + return "OSS4-HMAC-SHA256" . "\n" . $datetime . "\n" . $scope . "\n" . $hashedRequest; + } + + private function calcCanonicalRequest($method, $resourcePath, array $query, array $headers, array $additionalHeaders) + { + /* + Canonical Request + HTTP Verb + "\n" + + Canonical URI + "\n" + + Canonical Query String + "\n" + + Canonical Headers + "\n" + + Additional Headers + "\n" + + Hashed PayLoad + */ + + //Canonical Uri + $canonicalUri = str_replace(array('%2F'), array('/'), rawurlencode($resourcePath)); + //Canonical Query + $querySigned = array(); + foreach ($query as $key => $value) { + $querySigned[rawurlencode($key)] = rawurlencode($value); + } + ksort($querySigned); + $sortedQueryList = array(); + foreach ($querySigned as $key => $value) { + if (strlen($value) > 0) { + $sortedQueryList[] = $key . '=' . $value; + } else { + $sortedQueryList[] = $key; + } + } + $canonicalQuery = implode('&', $sortedQueryList); + //Canonical Headers + $headersSigned = array(); + foreach ($headers as $key => $value) { + $lowk = strtolower($key); + if (SignerV4::isDefaultSignedHeader($lowk) || + in_array($lowk, $additionalHeaders)) { + $headersSigned[$lowk] = trim($value); + } + } + ksort($headersSigned); + $canonicalizedHeaders = ''; + foreach ($headersSigned as $key => $value) { + $canonicalizedHeaders .= $key . ':' . $value . "\n"; + } + //Additional Headers + $canonicalAdditionalHeaders = implode(';', $additionalHeaders); + $hashPayload = "UNSIGNED-PAYLOAD"; + if (isset($headersSigned['x-oss-content-sha256'])) { + $hashPayload = $headersSigned['x-oss-content-sha256']; + } + + $stringToSign = $method . "\n" + . $canonicalUri . "\n" + . $canonicalQuery . "\n" + . $canonicalizedHeaders . "\n" + . $canonicalAdditionalHeaders . "\n" + . $hashPayload; + return $stringToSign; + } + + private function buildScope($date, $region, $product) + { + return $date . "/" . $region . "/" . $product . "/aliyun_v4_request"; + } + + private function calcSignature($secret, $date, $region, $product, $stringToSign) + { + $h1Key = hash_hmac("sha256", $date, "aliyun_v4" . $secret, true); + $h2Key = hash_hmac("sha256", $region, $h1Key, true); + $h3Key = hash_hmac("sha256", $product, $h2Key, true); + $h4Key = hash_hmac("sha256", "aliyun_v4_request", $h3Key, true); + return bin2hex(hash_hmac("sha256", $stringToSign, $h4Key, true)); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AssumeRole.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AssumeRole.php new file mode 100644 index 0000000..e47f705 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AssumeRole.php @@ -0,0 +1,32 @@ +$name = $value; + } + + public function __construct() + { + parent::__construct(); + $this->RoleSessionName = "sts"; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientAsyncProcessObjectTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientAsyncProcessObjectTest.php new file mode 100644 index 0000000..cbf85e3 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientAsyncProcessObjectTest.php @@ -0,0 +1,68 @@ +client = $this->ossClient; + $this->bucketName = $this->bucket; + + $url = 'https://oss-console-img-demo-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/video.mp4?spm=a2c4g.64555.0.0.515675979u4B8w&file=video.mp4'; + $file_name = "video.mp4"; + $fp = fopen($file_name, 'w'); + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_FILE, $fp); + curl_exec($ch); + curl_close($ch); + fclose($fp); + + $this->local_file = $file_name; + $this->object = "oss-example.mp4"; + + Common::waitMetaSync(); + $this->client->uploadFile($this->bucketName, $this->object, $this->local_file); + } + + protected function tearDown(): void + { + parent::tearDown(); + unlink($this->local_file); + } + + public function testAsyncProcessObject() + { + + try { + $object = 'php-async-copy'; + $process = 'video/convert,f_avi,vcodec_h265,s_1920x1080,vb_2000000,fps_30,acodec_aac,ab_100000,sn_1'. + '|sys/saveas'. + ',o_'.$this->base64url_encode($object). + ',b_'.$this->base64url_encode($this->bucketName); + $result = $this->client->asyncProcessObject($this->bucketName, $this->object, $process); + }catch (OssException $e){ + $this->assertEquals($e->getErrorCode(),"Imm Client"); + $this->assertTrue(strpos($e->getErrorMessage(), "ResourceNotFound, The specified resource Attachment is not found") !== false); + } + + } + + private function base64url_encode($data) + { + return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientForcePathStyleTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientForcePathStyleTest.php new file mode 100644 index 0000000..fd4540a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientForcePathStyleTest.php @@ -0,0 +1,50 @@ + OssClient::OSS_SIGNATURE_VERSION_V4, + 'hostType' => OssClient::OSS_HOST_TYPE_PATH_STYLE, + ); + $this->ossClient = Common::getOssClient($config); + + try { + $this->ossClient->getBucketInfo($this->bucket); + } catch (OssException $e) { + $this->assertEquals($e->getErrorCode(), "SecondLevelDomainForbidden"); + $this->assertTrue(true); + } + + try { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $this->ossClient->putObject($this->bucket, $object, 'hi oss'); + } catch (OssException $e) { + $this->assertEquals($e->getErrorCode(), "SecondLevelDomainForbidden"); + $this->assertTrue(true); + } + + try { + $endpoint = Common::getEndpoint(); + $endpoint = str_replace(array('http://', 'https://'), '', $endpoint); + $strUrl = $this->bucket . '.' . $endpoint . "/" . $object; + $signUrl = $this->ossClient->signUrl($this->bucket, $object, 3600); + $this->assertTrue(strpos($signUrl, $strUrl) !== false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignV4Test.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignV4Test.php new file mode 100644 index 0000000..cc126ac --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignV4Test.php @@ -0,0 +1,326 @@ +ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + + //testGetSignedUrlForPuttingObject + $object = "a.file"; + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT"); + $content = file_get_contents(__FILE__); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + sleep(1); + + // test Get SignedUrl For Putting Object From File + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', 'txt'); + $request->set_read_file($file); + $request->set_read_stream_size(sprintf('%u', filesize($file))); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + sleep(1); + // test SignedUrl With Exception + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "POST", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "method is invalid") == false) { + $this->assertTrue(false); + } + } + + // test GetgenPreSignedUrl For GettingObject + $object = "a.file"; + $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $expires = time() + 3600; + try { + $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + // test Get genPreSignedUrl Vs SignedUrl + + $object = "object-vs.file"; + $signedUrl1 = '245'; + $signedUrl2 = '123'; + $expiration = 0; + + do { + usleep(500000); + $begin = time(); + $expiration = time() + 3600; + $signedUrl1 = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expiration); + $signedUrl2 = $this->ossClient->signUrl($this->bucket, $object, 3600); + $end = time(); + } while ($begin != $end); + $this->assertEquals($signedUrl1, $signedUrl2); + $this->assertTrue(strpos($signedUrl1, 'x-oss-expires=') !== false); + + $object = "a.file"; + $options = array( + OssClient::OSS_HEADERS => array( + 'name' => 'aliyun', + 'email' => 'aliyun@aliyun.com', + 'book' => 'english', + ), + OssClient::OSS_ADDITIONAL_HEADERS => array("name", "email") + ); + $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__), $options); + $expires = time() + 3600; + try { + $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires, "GET", $options); + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->add_header('name', 'aliyun'); + $request->add_header('email', 'aliyun@aliyun.com'); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + + try { + $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + + + } + + public function testObjectWithStsClientSignV4() + { + $object = "a.file"; + $this->stsOssClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $timeout = 3600; + try { + $signedUrl = $this->stsOssClient->signUrl($this->bucket, $object, $timeout); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + + //testGetSignedUrlForPuttingObject + $object = "a.file"; + $timeout = 3600; + try { + $signedUrl = $this->stsOssClient->signUrl($this->bucket, $object, $timeout, "PUT"); + $content = file_get_contents(__FILE__); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + sleep(1); + + // test Get SignedUrl For Putting Object From File + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->stsOssClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', 'txt'); + $request->set_read_file($file); + $request->set_read_stream_size(sprintf('%u', filesize($file))); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + sleep(1); + // test SignedUrl With Exception + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->stsOssClient->signUrl($this->bucket, $object, $timeout, "POST", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "method is invalid") == false) { + $this->assertTrue(false); + } + } + + // test GetgenPreSignedUrl For GettingObject + $object = "a.file"; + $this->stsOssClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $expires = time() + 3600; + try { + $signedUrl = $this->stsOssClient->generatePresignedUrl($this->bucket, $object, $expires); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + } catch (OssException $e) { + $this->assertFalse(true); + } + + // test Get genPreSignedUrl Vs SignedUrl + + $object = "object-vs.file"; + + do { + usleep(500000); + $begin = time(); + $expiration = time() + 3600; + $signedUrl1 = $this->stsOssClient->generatePresignedUrl($this->bucket, $object, $expiration); + $signedUrl2 = $this->stsOssClient->signUrl($this->bucket, $object, 3600); + $end = time(); + } while ($begin != $end); + $this->assertEquals($signedUrl1, $signedUrl2); + $this->assertTrue(strpos($signedUrl1, 'x-oss-expires=') !== false); + + $object = "a.file"; + $options = array( + OssClient::OSS_HEADERS => array( + 'name' => 'aliyun', + 'email' => 'aliyun@aliyun.com', + 'book' => 'english', + ), + OssClient::OSS_ADDITIONAL_HEADERS => array("name", "email") + ); + $this->stsOssClient->putObject($this->bucket, $object, file_get_contents(__FILE__), $options); + $expires = time() + 3600; + try { + $signedUrl = $this->stsOssClient->generatePresignedUrl($this->bucket, $object, $expires, "GET", $options); + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->add_header('name', 'aliyun'); + $request->add_header('email', 'aliyun@aliyun.com'); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + } + + protected function tearDown(): void + { + $this->ossClient->deleteObject($this->bucket, "a.file"); + parent::tearDown(); + } + + protected function setUp(): void + { + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4 + ); + $this->bucket = Common::getBucketName() . '-' . time(); + $this->ossClient = Common::getOssClient($config); + $this->ossClient->createBucket($this->bucket); + Common::waitMetaSync(); + $this->stsOssClient = Common::getStsOssClient($config); + Common::waitMetaSync(); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureV4Test.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureV4Test.php new file mode 100644 index 0000000..ed26374 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureV4Test.php @@ -0,0 +1,1409 @@ +ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertTrue(false); + } + + // test GetObjectMeta + try { + $res = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertFalse(isset($res['Content-Encoding'])); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + try { + $res = $this->ossClient->getObjectMeta($this->bucket, $object, $options); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertFalse(isset($res['content-length'])); + $this->assertEquals('gzip', $res['content-encoding']); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + try { + $res = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + $res = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_LAST_MODIFIED => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + + try { + $res = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_ETAG => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $result = $this->ossClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertEquals('stringtype', $result[0]); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $this->ossClient->uploadFile($this->bucket, $object, "notexist.txt", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('notexist.txt file does not exist', $e->getMessage()); + } + + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + /** + * Upload the local file to object + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local file + */ + $localfile = "upload-test-object-name.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->ossClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertTrue(file_get_contents($localfile) === file_get_contents(__FILE__)); + if (file_exists($localfile)) { + unlink($localfile); + } + + /** + * Download the file to the local file. no such key + */ + $localfile = "upload-test-object-name-no-such-key.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->ossClient->getObject($this->bucket, $object . "no-such-key", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + $this->assertFalse(file_exists($localfile)); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Download the file to the content. no such key + */ + try { + $result = $this->ossClient->getObject($this->bucket, $object . "no-such-key"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * List the files in your bucket. + */ + $prefix = ''; + $delimiter = '/'; + $next_marker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $next_marker, + ); + + try { + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * Set the meta information for the file + */ + $from_bucket = $this->bucket; + $from_object = "oss-php-sdk-test/upload-test-object-name.txt"; + $to_bucket = $from_bucket; + $to_object = $from_object; + $copy_options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + try { + $this->ossClient->copyObject($from_bucket, $from_object, $to_bucket, $to_object, $copy_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $objectMeta = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete single file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $this->ossClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete multiple files + */ + $object1 = "oss-php-sdk-test/upload-test-object-name.txt"; + $object2 = "oss-php-sdk-test/upload-test-object-name.txt.copy"; + $list = array($object1, $object2); + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object2)); + + $result = $this->ossClient->deleteObjects($this->bucket, $list); + $this->assertEquals($list[0], $result[0]); + $this->assertEquals($list[1], $result[1]); + + $result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => 'true')); + $this->assertEquals(array(), $result); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object2)); + + $this->ossClient->putObject($this->bucket, $object, $content); + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => true)); + $this->assertEquals(array(), $result); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + + $this->assertFalse(true); + } + + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + + /** + * Append the upload string + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, array(OssClient::OSS_LENGTH => strlen($content_array[2]))); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[2])); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append the upload of invalid local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, "invalid-file-path", 0); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + /** + * Append the upload of local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, $position); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + $options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + + /** + * Append upload with option + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, "Hello OSS, ", 0, $options); + $position = $this->ossClient->appendObject($this->bucket, $object, "Hi OSS.", $position); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + try { + $objectMeta = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $options = array(OssClient::OSS_CHECK_MD5 => true); + + $content = file_get_contents(__FILE__); + /** + * Upload data to start MD5 + */ + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Upload file to start MD5 + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $object = "oss-php-sdk-test/append-test-object-name.txt"; + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + $options = array(OssClient::OSS_CHECK_MD5 => true); + + /** + * Append the upload string + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0, $options); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[1])); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append upload of local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, $position, $options); + $this->assertEquals($position, (sprintf('%u', filesize(__FILE__)) * 2)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $options = array( + OssClient::OSS_HEADERS => array( + "Content-Type" => "application/octet-stream", + "name" => "aliyun", + "email" => "aliyun@aliyun.com", + ), + OssClient::OSS_ADDITIONAL_HEADERS => array('name', 'email') + ); + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + try { + $content = $this->ossClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + } + + public function testObjectKeyWithQuestionMark() + { + /** + * Upload the local variable to bucket + */ + $object = "oss-php-sdk-test/??/upload-test-object-name???123??123??.txt"; + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + + /** + * Upload the local file to object + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $this->ossClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testBaseInterfaceForBucekt() + { + $this->ossClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $bucketListInfo = $this->ossClient->listBuckets(); + $this->assertNotNull($bucketListInfo); + + $bucketList = $bucketListInfo->getBucketList(); + $this->assertTrue(is_array($bucketList)); + $this->assertGreaterThan(0, count($bucketList)); + + $this->ossClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + Common::waitMetaSync(); + $this->assertEquals($this->ossClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $this->assertTrue($this->ossClient->doesBucketExist($this->bucket)); + $this->assertFalse($this->ossClient->doesBucketExist($this->bucket . '-notexist')); + + $this->assertNotNull($this->ossClient->getBucketLocation($this->bucket)); + + $res = $this->ossClient->getBucketMeta($this->bucket); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertNotNull($res['x-oss-bucket-region']); + } + + public function testBaseInterfaceForObjectWithSts() + { + + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $this->stsOssClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertTrue(false); + } + + // test GetObjectMeta + try { + $res = $this->stsOssClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertTrue(isset($res['content-encoding'])); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + try { + $res = $this->stsOssClient->getObjectMeta($this->bucket, $object, $options); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertEquals('gzip', $res['content-encoding']); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + try { + $res = $this->stsOssClient->getObject($this->bucket, $object, $options); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + $res = $this->stsOssClient->getObject($this->bucket, $object, array(OssClient::OSS_LAST_MODIFIED => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + + try { + $res = $this->stsOssClient->getObject($this->bucket, $object, array(OssClient::OSS_ETAG => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $result = $this->stsOssClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertEquals('stringtype', $result[0]); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $result = $this->stsOssClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $this->stsOssClient->uploadFile($this->bucket, $object, "notexist.txt", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('notexist.txt file does not exist', $e->getMessage()); + } + + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->stsOssClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + + /** + * Upload the local file to object + */ + try { + $this->stsOssClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local file + */ + $localfile = "upload-test-object-name.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->stsOssClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertTrue(file_get_contents($localfile) === file_get_contents(__FILE__)); + if (file_exists($localfile)) { + unlink($localfile); + } + + /** + * Download the file to the local file. no such key + */ + $localfile = "upload-test-object-name-no-such-key.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->stsOssClient->getObject($this->bucket, $object . "no-such-key", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + $this->assertFalse(file_exists($localfile)); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Download the file to the content. no such key + */ + try { + $result = $this->stsOssClient->getObject($this->bucket, $object . "no-such-key"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->stsOssClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * List the files in your bucket. + */ + $prefix = ''; + $delimiter = '/'; + $next_marker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $next_marker, + ); + + try { + $listObjectInfo = $this->stsOssClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * Set the meta information for the file + */ + $from_bucket = $this->bucket; + $from_object = "oss-php-sdk-test/upload-test-object-name.txt"; + $to_bucket = $from_bucket; + $to_object = $from_object; + $copy_options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + try { + $this->stsOssClient->copyObject($from_bucket, $from_object, $to_bucket, $to_object, $copy_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $objectMeta = $this->stsOssClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete single file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + + try { + $this->assertTrue($this->stsOssClient->doesObjectExist($this->bucket, $object)); + $this->stsOssClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->stsOssClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete multiple files + */ + $object1 = "oss-php-sdk-test/upload-test-object-name.txt"; + $object2 = "oss-php-sdk-test/upload-test-object-name.txt.copy"; + $list = array($object1, $object2); + try { + $this->assertTrue($this->stsOssClient->doesObjectExist($this->bucket, $object2)); + + $result = $this->stsOssClient->deleteObjects($this->bucket, $list); + $this->assertEquals($list[0], $result[0]); + $this->assertEquals($list[1], $result[1]); + + $result = $this->stsOssClient->deleteObjects($this->bucket, $list, array('quiet' => 'true')); + $this->assertEquals(array(), $result); + $this->assertFalse($this->stsOssClient->doesObjectExist($this->bucket, $object2)); + + $this->stsOssClient->putObject($this->bucket, $object, $content); + $this->assertTrue($this->stsOssClient->doesObjectExist($this->bucket, $object)); + $result = $this->stsOssClient->deleteObjects($this->bucket, $list, array('quiet' => true)); + $this->assertEquals(array(), $result); + $this->assertFalse($this->stsOssClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + + $this->assertFalse(true); + } + + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + + /** + * Append the upload string + */ + try { + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[0], 0); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[1], $position); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[2], $position, array(OssClient::OSS_LENGTH => strlen($content_array[2]))); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[2])); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append the upload of invalid local files + */ + try { + $position = $this->stsOssClient->appendFile($this->bucket, $object, "invalid-file-path", 0); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + /** + * Append the upload of local files + */ + try { + $position = $this->stsOssClient->appendFile($this->bucket, $object, __FILE__, 0); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->stsOssClient->appendFile($this->bucket, $object, __FILE__, $position); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + $options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + + /** + * Append upload with option + */ + try { + $position = $this->stsOssClient->appendObject($this->bucket, $object, "Hello OSS, ", 0, $options); + $position = $this->stsOssClient->appendObject($this->bucket, $object, "Hi OSS.", $position); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + try { + $objectMeta = $this->stsOssClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $options = array(OssClient::OSS_CHECK_MD5 => true); + + $content = file_get_contents(__FILE__); + /** + * Upload data to start MD5 + */ + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Upload file to start MD5 + */ + try { + $this->stsOssClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $object = "oss-php-sdk-test/append-test-object-name.txt"; + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + $options = array(OssClient::OSS_CHECK_MD5 => true); + + /** + * Append the upload string + */ + try { + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[0], 0, $options); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[1], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[2], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[1])); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append upload of local files + */ + try { + $position = $this->stsOssClient->appendFile($this->bucket, $object, __FILE__, 0, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->stsOssClient->appendFile($this->bucket, $object, __FILE__, $position, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $options = array( + OssClient::OSS_HEADERS => array( + "Content-Type" => "application/octet-stream", + "name" => "aliyun", + "email" => "aliyun@aliyun.com", + ), + OssClient::OSS_ADDITIONAL_HEADERS => array('name', 'email') + ); + try { + $this->stsOssClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $content = $this->stsOssClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + } + + public function testBaseInterfaceForBucektWithSts() + { + $options = array( + OssClient::OSS_HEADERS => array( + "Content-Type" => "application/octet-stream", + "name" => "aliyun", + "email" => "aliyun@aliyun.com", + ), + OssClient::OSS_ADDITIONAL_HEADERS => array('name', 'email') + ); + $this->stsOssClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE, $options); + + $bucketListInfo = $this->stsOssClient->listBuckets($options); + $this->assertNotNull($bucketListInfo); + + $bucketList = $bucketListInfo->getBucketList(); + $this->assertTrue(is_array($bucketList)); + $this->assertGreaterThan(0, count($bucketList)); + + $this->stsOssClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE, $options); + Common::waitMetaSync(); + $this->assertEquals($this->stsOssClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $this->assertTrue($this->stsOssClient->doesBucketExist($this->bucket)); + $this->assertFalse($this->stsOssClient->doesBucketExist($this->bucket . '-notexist')); + + $this->assertNotNull($this->stsOssClient->getBucketLocation($this->bucket)); + + $res = $this->stsOssClient->getBucketMeta($this->bucket, $options); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertNotNull($res['x-oss-bucket-region']); + } + + protected function setUp(): void + { + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4 + ); + $this->bucket = Common::getBucketName() . '-' . time(); + $this->ossClient = Common::getOssClient($config); + $this->ossClient->createBucket($this->bucket); + Common::waitMetaSync(); + $this->stsOssClient = Common::getStsOssClient($config); + Common::waitMetaSync(); + } + + protected function tearDown(): void + { + if (!$this->ossClient->doesBucketExist($this->bucket)) { + return; + } + + $objects = $this->ossClient->listObjects( + $this->bucket, array('max-keys' => 1000, 'delimiter' => ''))->getObjectList(); + $keys = array(); + foreach ($objects as $obj) { + $keys[] = $obj->getKey(); + } + if (count($keys) > 0) { + $this->ossClient->deleteObjects($this->bucket, $keys); + } + $uploads = $this->ossClient->listMultipartUploads($this->bucket)->getUploads(); + foreach ($uploads as $up) { + $this->ossClient->abortMultipartUpload($this->bucket, $up->getKey(), $up->getUploadId()); + } + + $this->ossClient->deleteBucket($this->bucket); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SignerTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SignerTest.php new file mode 100644 index 0000000..f92bbd2 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SignerTest.php @@ -0,0 +1,558 @@ +set_method("PUT"); + $bucket = "examplebucket"; + $object = "nelson"; + + $request->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request->add_header("Content-Type", "text/html"); + $request->add_header("x-oss-meta-author", "alice"); + $request->add_header("x-oss-meta-magic", "abracadabra"); + $request->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signer = new SignerV1(); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request, $credentials, $signingOpt); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\n/examplebucket/nelson"; + + $this->assertEquals($signToString, $signingOpt['string_to_sign']); + $this->assertEquals('OSS ak:kSHKmLxlyEAKtZPkJhG9bZb5k7M=', $request->request_headers['Authorization']); + + // case 2 + $request2 = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com?acl"); + $request2->set_method("PUT"); + + $request2->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request2->add_header("Content-Type", "text/html"); + $request2->add_header("x-oss-meta-author", "alice"); + $request2->add_header("x-oss-meta-magic", "abracadabra"); + $request2->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request2->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signer = new SignerV1(); + + $signingOpt2 = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request2, $credentials, $signingOpt2); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\n/examplebucket/nelson?acl"; + + $this->assertEquals($signToString, $signingOpt2['string_to_sign']); + $this->assertEquals('OSS ak:/afkugFbmWDQ967j1vr6zygBLQk=', $request2->request_headers['Authorization']); + + // case 3 with non-signed query + $request3 = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com?acl&non-signed-key=value"); + $request3->set_method("PUT"); + + $request3->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request3->add_header("Content-Type", "text/html"); + $request3->add_header("x-oss-meta-author", "alice"); + $request3->add_header("x-oss-meta-magic", "abracadabra"); + $request3->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request3->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signingOpt3 = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request3, $credentials, $signingOpt3); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\n/examplebucket/nelson?acl"; + + $this->assertEquals($signToString, $signingOpt3['string_to_sign']); + $this->assertEquals('OSS ak:/afkugFbmWDQ967j1vr6zygBLQk=', $request3->request_headers['Authorization']); + } + + public function testSignerV1HeaderWithToken() + { + // case 1 + $credentials = new Credentials("ak", "sk", "token"); + $request = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com"); + $request->set_method("PUT"); + $bucket = "examplebucket"; + $object = "nelson"; + + $request->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request->add_header("Content-Type", "text/html"); + $request->add_header("x-oss-meta-author", "alice"); + $request->add_header("x-oss-meta-magic", "abracadabra"); + $request->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signer = new SignerV1(); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request, $credentials, $signingOpt); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\nx-oss-security-token:token\n/examplebucket/nelson"; + + $this->assertEquals($signToString, $signingOpt['string_to_sign']); + $this->assertEquals('OSS ak:H3PAlN3Vucn74tPVEqaQC4AnLwQ=', $request->request_headers['Authorization']); + $this->assertEquals('token', $request->request_headers['x-oss-security-token']); + + // case 2 + $request2 = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com?acl"); + $request2->set_method("PUT"); + + $request2->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request2->add_header("Content-Type", "text/html"); + $request2->add_header("x-oss-meta-author", "alice"); + $request2->add_header("x-oss-meta-magic", "abracadabra"); + $request2->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request2->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signer = new SignerV1(); + + $signingOpt2 = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request2, $credentials, $signingOpt2); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\nx-oss-security-token:token\n/examplebucket/nelson?acl"; + + $this->assertEquals($signToString, $signingOpt2['string_to_sign']); + $this->assertEquals("OSS ak:yeceHMAsgusDPCR979RJcLtd7RI=", $request2->request_headers['Authorization']); + + // case 3 with non-signed query + $request3 = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com?acl&non-signed-key=value"); + $request3->set_method("PUT"); + + $request3->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request3->add_header("Content-Type", "text/html"); + $request3->add_header("x-oss-meta-author", "alice"); + $request3->add_header("x-oss-meta-magic", "abracadabra"); + $request3->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request3->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signingOpt3 = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request3, $credentials, $signingOpt3); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\nx-oss-security-token:token\n/examplebucket/nelson?acl"; + + $this->assertEquals($signToString, $signingOpt3['string_to_sign']); + $this->assertEquals('OSS ak:yeceHMAsgusDPCR979RJcLtd7RI=', $request2->request_headers['Authorization']); + } + + public function testSignerV1Presign() + { + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/key?versionId=versionId"); + $request->set_method("GET"); + $bucket = "bucket"; + $object = "key"; + + $signer = new SignerV1(); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'expiration' => 1699807420, + ); + $signer->presign($request, $credentials, $signingOpt); + + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + + $this->assertEquals('1699807420', $query['Expires']); + $this->assertEquals('ak', $query['OSSAccessKeyId']); + $this->assertEquals('dcLTea+Yh9ApirQ8o8dOPqtvJXQ=', $query['Signature']); + $this->assertEquals('versionId', $query['versionId']); + $this->assertEquals('/key', $parsed_url['path']); + } + + public function testSignerV1PresignWithToken() + { + $credentials = new Credentials("ak", "sk", "token"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/key%2B123?versionId=versionId"); + $request->set_method("GET"); + $bucket = "bucket"; + $object = "key+123"; + + $signer = new SignerV1(); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'expiration' => 1699808204, + ); + $signer->presign($request, $credentials, $signingOpt); + + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + + $this->assertEquals('1699808204', $query['Expires']); + $this->assertEquals('ak', $query['OSSAccessKeyId']); + $this->assertEquals('jzKYRrM5y6Br0dRFPaTGOsbrDhY=', $query['Signature']); + $this->assertEquals('versionId', $query['versionId']); + $this->assertEquals('token', $query['security-token']); + $this->assertEquals('/key%2B123', $parsed_url['path']); + } + + public function testSignerV4Header() + { + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "text/plain"); + $request->add_header("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702743657)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + ); + $signer->sign($request, $credentials, $signingOpt); + + $authPat = "OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,Signature=e21d18daa82167720f9b1047ae7e7f1ce7cb77a31e8203a7d5f4624fa0284afe"; + $this->assertEquals($authPat, $request->request_headers['Authorization']); + } + + public function testSignerV4HeaderWithToken() + { + // case 1 + $credentials = new Credentials("ak", "sk", "token"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "text/plain"); + $request->add_header("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702784856)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + ); + $signer->sign($request, $credentials, $signingOpt); + + $authPat = "OSS4-HMAC-SHA256 Credential=ak/20231217/cn-hangzhou/oss/aliyun_v4_request,Signature=b94a3f999cf85bcdc00d332fbd3734ba03e48382c36fa4d5af5df817395bd9ea"; + $this->assertEquals($authPat, $request->request_headers['Authorization']); + } + + public function testSignerV4AdditionalHeaders() + { + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "text/plain"); + $request->add_header("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702747512)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'additionalHeaders' => array("ZAbc", "abc") + ); + $signer->sign($request, $credentials, $signingOpt); + + $authPat = "OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,AdditionalHeaders=abc;zabc,Signature=4a4183c187c07c8947db7620deb0a6b38d9fbdd34187b6dbaccb316fa251212f"; + $this->assertEquals($authPat, $request->request_headers['Authorization']); + + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "text/plain"); + $request->add_header("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702747512)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'additionalHeaders' => array("x-oss-no-exist", "ZAbc", "x-oss-head1", "abc") + ); + $signer->sign($request, $credentials, $signingOpt); + + $authPat = "OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,AdditionalHeaders=abc;zabc,Signature=4a4183c187c07c8947db7620deb0a6b38d9fbdd34187b6dbaccb316fa251212f"; + $this->assertEquals($authPat, $request->request_headers['Authorization']); + } + + public function testSignerV4Presign() + { + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "application/octet-stream"); + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702781677)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'expiration' => 1702782276, + ); + $signer->presign($request, $credentials, $signingOpt); + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + $this->assertEquals('599', $query['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $query['x-oss-credential']); + $this->assertEquals('a39966c61718be0d5b14e668088b3fa07601033f6518ac7b523100014269c0fe', $query['x-oss-signature']); + $this->assertFalse(isset($query['x-oss-additional-headers'])); + } + + public function testSignerV4PresignWithToken() + { + // case 1 + $credentials = new Credentials("ak", "sk", "token"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "application/octet-stream"); + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702785388)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'expiration' => 1702785987, + ); + $signer->presign($request, $credentials, $signingOpt); + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + $this->assertEquals('599', $query['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $query['x-oss-credential']); + $this->assertEquals('3817ac9d206cd6dfc90f1c09c00be45005602e55898f26f5ddb06d7892e1f8b5', $query['x-oss-signature']); + $this->assertFalse(isset($query['x-oss-additional-headers'])); + //print($request->request_url); + } + + public function testSignerV4PresignWithAdditionalHeaders() + { + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "application/octet-stream"); + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702783809)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'expiration' => 1702784408, + 'additionalHeaders' => array("ZAbc", "abc") + ); + $signer->presign($request, $credentials, $signingOpt); + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + $this->assertEquals('20231217T033009Z', $query['x-oss-date']); + $this->assertEquals('599', $query['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $query['x-oss-credential']); + $this->assertEquals('6bd984bfe531afb6db1f7550983a741b103a8c58e5e14f83ea474c2322dfa2b7', $query['x-oss-signature']); + $this->assertEquals('abc;zabc', $query['x-oss-additional-headers']); + } +} + + diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsBase.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsBase.php new file mode 100644 index 0000000..5b1f1d2 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsBase.php @@ -0,0 +1,33 @@ +$name = $value; + } + + public function __construct() + { + $this->Timestamp = gmdate('Y-m-d\TH:i:s\Z'); + $this->SignatureNonce = time().rand(10000,99999); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsClient.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsClient.php new file mode 100644 index 0000000..0aae601 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsClient.php @@ -0,0 +1,108 @@ +generateSignedURL($params); + + $response = $this->sendRequest($request_url, $format); + + $result= $this->parseResponse($response, $format); + + return $result; + } + + private function sendRequest($url, $format) + { + $curl_handle = curl_init(); + + curl_setopt($curl_handle, CURLOPT_URL, $url); + curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, "GET"); + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST,false); + curl_setopt($curl_handle, CURLOPT_HEADER, true); + + $response = curl_exec($curl_handle); + $headerSize = curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE); + $response = substr($response, $headerSize); + + if (curl_getinfo($curl_handle, CURLINFO_HTTP_CODE) != '200') { + $errors = $this->parseResponse($response, $format); + throw new OssException($errors->Code); + } + + curl_close($curl_handle); + + return $response; + } + + private function parseResponse($body, $format) + { + if ("JSON" == $format) { + $respObject = json_decode($body); + } elseif ("XML" == $format) { + $respObject = @simplexml_load_string($body); + } elseif ("RAW" == $format) { + $respObject = $body; + } + return $respObject; + } + + private function generateSignedURL($arr) + { + $request_url = 'https://sts.aliyuncs.com/?'; + + foreach ($arr as $key=>$item) { + if (is_null($item)) unset($arr[$key]); + } + + $Signature = $this->computeSignature($arr, $this->AccessSecret); + ksort($arr); + foreach ($arr as $key => $value) { + $request_url .= $key."=".urlencode($value)."&"; + } + $request_url .="Signature=".urlencode($Signature); + + return $request_url; + } + + private function computeSignature($parameters, $accessKeySecret) + { + ksort($parameters); + $canonicalizedQueryString = ''; + foreach ($parameters as $key => $value) { + $canonicalizedQueryString .= '&' . $this->percentEncode($key). '=' . $this->percentEncode($value); + } + $stringToSign = 'GET&%2F&' . $this->percentencode(substr($canonicalizedQueryString, 1)); + $signature = $this->signString($stringToSign, $accessKeySecret."&"); + + return $signature; + } + + private function signString($source, $accessSecret) + { + return base64_encode(hash_hmac('sha1', $source, $accessSecret, true)); + } + + private function percentEncode($str) + { + $res = urlencode($str); + $res = preg_replace('/\+/', '%20', $res); + $res = preg_replace('/\*/', '%2A', $res); + $res = preg_replace('/%7E/', '~', $res); + return $res; + } +} diff --git a/vendor/bin/jp.php b/vendor/bin/jp.php new file mode 100644 index 0000000..fc4e0a7 --- /dev/null +++ b/vendor/bin/jp.php @@ -0,0 +1,119 @@ +#!/usr/bin/env php +realpath = realpath($opened_path) ?: $opened_path; + $opened_path = $this->realpath; + $this->handle = fopen($this->realpath, $mode); + $this->position = 0; + + return (bool) $this->handle; + } + + public function stream_read($count) + { + $data = fread($this->handle, $count); + + if ($this->position === 0) { + $data = preg_replace('{^#!.*\r?\n}', '', $data); + } + + $this->position += strlen($data); + + return $data; + } + + public function stream_cast($castAs) + { + return $this->handle; + } + + public function stream_close() + { + fclose($this->handle); + } + + public function stream_lock($operation) + { + return $operation ? flock($this->handle, $operation) : true; + } + + public function stream_seek($offset, $whence) + { + if (0 === fseek($this->handle, $offset, $whence)) { + $this->position = ftell($this->handle); + return true; + } + + return false; + } + + public function stream_tell() + { + return $this->position; + } + + public function stream_eof() + { + return feof($this->handle); + } + + public function stream_stat() + { + return array(); + } + + public function stream_set_option($option, $arg1, $arg2) + { + return true; + } + + public function url_stat($path, $flags) + { + $path = substr($path, 17); + if (file_exists($path)) { + return stat($path); + } + + return false; + } + } + } + + if ( + (function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true)) + || (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) + ) { + return include("phpvfscomposer://" . __DIR__ . '/..'.'/mtdowling/jmespath.php/bin/jp.php'); + } +} + +return include __DIR__ . '/..'.'/mtdowling/jmespath.php/bin/jp.php'; diff --git a/vendor/bin/jp.php.bat b/vendor/bin/jp.php.bat new file mode 100644 index 0000000..9af045e --- /dev/null +++ b/vendor/bin/jp.php.bat @@ -0,0 +1,5 @@ +@ECHO OFF +setlocal DISABLEDELAYEDEXPANSION +SET BIN_TARGET=%~dp0/jp.php +SET COMPOSER_RUNTIME_BIN_DIR=%~dp0 +php "%BIN_TARGET%" %* diff --git a/vendor/mtdowling/jmespath.php/bin/jp.php b/vendor/mtdowling/jmespath.php/bin/jp.php new file mode 100644 index 0000000..c8433b5 --- /dev/null +++ b/vendor/mtdowling/jmespath.php/bin/jp.php @@ -0,0 +1,74 @@ +#!/usr/bin/env php +check(); +unset($xdebug); + +$dir = isset($argv[1]) ? $argv[1] : __DIR__ . '/../tests/compliance/perf'; +is_dir($dir) or die('Dir not found: ' . $dir); +// Warm up the runner +\JmesPath\Env::search('foo', []); + +$total = 0; +foreach (glob($dir . '/*.json') as $file) { + $total += runSuite($file); +} +echo "\nTotal time: {$total}\n"; + +function runSuite($file) +{ + $contents = file_get_contents($file); + $json = json_decode($contents, true); + $total = 0; + foreach ($json as $suite) { + foreach ($suite['cases'] as $case) { + $total += runCase( + $suite['given'], + $case['expression'], + $case['name'] + ); + } + } + return $total; +} + +function runCase($given, $expression, $name) +{ + $best = 99999; + $runtime = \JmesPath\Env::createRuntime(); + + for ($i = 0; $i < 100; $i++) { + $t = microtime(true); + $runtime($expression, $given); + $tryTime = (microtime(true) - $t) * 1000; + if ($tryTime < $best) { + $best = $tryTime; + } + if (!getenv('CACHE')) { + $runtime = \JmesPath\Env::createRuntime(); + // Delete compiled scripts if not caching. + if ($runtime instanceof \JmesPath\CompilerRuntime) { + array_map('unlink', glob(sys_get_temp_dir() . '/jmespath_*.php')); + } + } + } + + printf("time: %07.4fms name: %s\n", $best, $name); + + return $best; +} diff --git a/vendor/myclabs/php-enum/stubs/Stringable.php b/vendor/myclabs/php-enum/stubs/Stringable.php new file mode 100644 index 0000000..4811af7 --- /dev/null +++ b/vendor/myclabs/php-enum/stubs/Stringable.php @@ -0,0 +1,11 @@ + + + + + + + + ./tests/PhpSpreadsheetTests + + + + ./src + + + diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IgnoredErrors.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IgnoredErrors.php new file mode 100644 index 0000000..ee4b515 --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IgnoredErrors.php @@ -0,0 +1,66 @@ +numberStoredAsText = $value; + + return $this; + } + + public function getNumberStoredAsText(): bool + { + return $this->numberStoredAsText; + } + + public function setFormula(bool $value): self + { + $this->formula = $value; + + return $this; + } + + public function getFormula(): bool + { + return $this->formula; + } + + public function setTwoDigitTextYear(bool $value): self + { + $this->twoDigitTextYear = $value; + + return $this; + } + + public function getTwoDigitTextYear(): bool + { + return $this->twoDigitTextYear; + } + + public function setEvalError(bool $value): self + { + $this->evalError = $value; + + return $this; + } + + public function getEvalError(): bool + { + return $this->evalError; + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/AxisText.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/AxisText.php new file mode 100644 index 0000000..cd9ba2c --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Chart/AxisText.php @@ -0,0 +1,56 @@ +font = new Font(); + $this->font->setSize(null, true); + } + + public function setRotation(?int $rotation): self + { + $this->rotation = $rotation; + + return $this; + } + + public function getRotation(): ?int + { + return $this->rotation; + } + + public function getFillColorObject(): ChartColor + { + $fillColor = $this->font->getChartColor(); + if ($fillColor === null) { + $fillColor = new ChartColor(); + $this->font->setChartColorFromObject($fillColor); + } + + return $fillColor; + } + + public function getFont(): Font + { + return $this->font; + } + + public function setFont(Font $font): self + { + $this->font = $font; + + return $this; + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Downloader.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Downloader.php new file mode 100644 index 0000000..e66ae42 --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Downloader.php @@ -0,0 +1,89 @@ + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xls' => 'application/vnd.ms-excel', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'csv' => 'text/csv', + 'html' => 'text/html', + 'pdf' => 'application/pdf', + ]; + + public function __construct(string $folder, string $filename, ?string $filetype = null) + { + if ((is_dir($folder) === false) || (is_readable($folder) === false)) { + throw new Exception("Folder {$folder} is not accessable"); + } + $filepath = "{$folder}/{$filename}"; + $this->filepath = (string) realpath($filepath); + $this->filename = basename($filepath); + if ((file_exists($this->filepath) === false) || (is_readable($this->filepath) === false)) { + throw new Exception("{$this->filename} not found, or cannot be read"); + } + + $filetype ??= pathinfo($filename, PATHINFO_EXTENSION); + if (array_key_exists(strtolower($filetype), self::CONTENT_TYPES) === false) { + throw new Exception("Invalid filetype: {$filetype} cannot be downloaded"); + } + $this->filetype = strtolower($filetype); + } + + public function download(): void + { + $this->headers(); + + readfile($this->filepath); + } + + public function headers(): void + { + ob_clean(); + + $this->contentType(); + $this->contentDisposition(); + $this->cacheHeaders(); + $this->fileSize(); + + flush(); + } + + protected function contentType(): void + { + header('Content-Type: ' . self::CONTENT_TYPES[$this->filetype]); + } + + protected function contentDisposition(): void + { + header('Content-Disposition: attachment;filename="' . $this->filename . '"'); + } + + protected function cacheHeaders(): void + { + header('Cache-Control: max-age=0'); + // If you're serving to IE 9, then the following may be needed + header('Cache-Control: max-age=1'); + + // If you're serving to IE over SSL, then the following may be needed + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified + header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 + header('Pragma: public'); // HTTP/1.0 + } + + protected function fileSize(): void + { + header('Content-Length: ' . filesize($this->filepath)); + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Handler.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Handler.php new file mode 100644 index 0000000..d05197c --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Helper/Handler.php @@ -0,0 +1,46 @@ +master = $master; + $this->formula = $formula; + } + + public function master(): string + { + return $this->master; + } + + public function formula(): string + { + return $this->formula; + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/DataValidations.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/DataValidations.php new file mode 100644 index 0000000..31748cb --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xml/DataValidations.php @@ -0,0 +1,177 @@ + DataValidation::OPERATOR_BETWEEN, + 'equal' => DataValidation::OPERATOR_EQUAL, + 'greater' => DataValidation::OPERATOR_GREATERTHAN, + 'greaterorequal' => DataValidation::OPERATOR_GREATERTHANOREQUAL, + 'less' => DataValidation::OPERATOR_LESSTHAN, + 'lessorequal' => DataValidation::OPERATOR_LESSTHANOREQUAL, + 'notbetween' => DataValidation::OPERATOR_NOTBETWEEN, + 'notequal' => DataValidation::OPERATOR_NOTEQUAL, + ]; + + private const TYPE_MAPPINGS = [ + 'textlength' => DataValidation::TYPE_TEXTLENGTH, + ]; + + private int $thisRow = 0; + + private int $thisColumn = 0; + + private function replaceR1C1(array $matches): string + { + return AddressHelper::convertToA1($matches[0], $this->thisRow, $this->thisColumn, false); + } + + public function loadDataValidations(SimpleXMLElement $worksheet, Spreadsheet $spreadsheet): void + { + $xmlX = $worksheet->children(Namespaces::URN_EXCEL); + $sheet = $spreadsheet->getActiveSheet(); + /** @var callable */ + $pregCallback = [$this, 'replaceR1C1']; + foreach ($xmlX->DataValidation as $dataValidation) { + $cells = []; + $validation = new DataValidation(); + + // set defaults + $validation->setShowDropDown(true); + $validation->setShowInputMessage(true); + $validation->setShowErrorMessage(true); + $validation->setShowDropDown(true); + $this->thisRow = 1; + $this->thisColumn = 1; + + foreach ($dataValidation as $tagName => $tagValue) { + $tagValue = (string) $tagValue; + $tagValueLower = strtolower($tagValue); + switch ($tagName) { + case 'Range': + foreach (explode(',', $tagValue) as $range) { + $cell = ''; + if (preg_match('/^R(\d+)C(\d+):R(\d+)C(\d+)$/', (string) $range, $selectionMatches) === 1) { + // range + $firstCell = Coordinate::stringFromColumnIndex((int) $selectionMatches[2]) + . $selectionMatches[1]; + $cell = $firstCell + . ':' + . Coordinate::stringFromColumnIndex((int) $selectionMatches[4]) + . $selectionMatches[3]; + $this->thisRow = (int) $selectionMatches[1]; + $this->thisColumn = (int) $selectionMatches[2]; + $sheet->getCell($firstCell); + } elseif (preg_match('/^R(\d+)C(\d+)$/', (string) $range, $selectionMatches) === 1) { + // cell + $cell = Coordinate::stringFromColumnIndex((int) $selectionMatches[2]) + . $selectionMatches[1]; + $sheet->getCell($cell); + $this->thisRow = (int) $selectionMatches[1]; + $this->thisColumn = (int) $selectionMatches[2]; + } elseif (preg_match('/^C(\d+)$/', (string) $range, $selectionMatches) === 1) { + // column + $firstCell = Coordinate::stringFromColumnIndex((int) $selectionMatches[1]) + . '1'; + $cell = $firstCell + . ':' + . Coordinate::stringFromColumnIndex((int) $selectionMatches[1]) + . ((string) AddressRange::MAX_ROW); + $this->thisColumn = (int) $selectionMatches[1]; + $sheet->getCell($firstCell); + } elseif (preg_match('/^R(\d+)$/', (string) $range, $selectionMatches)) { + // row + $firstCell = 'A' + . $selectionMatches[1]; + $cell = $firstCell + . ':' + . AddressRange::MAX_COLUMN + . $selectionMatches[1]; + $this->thisRow = (int) $selectionMatches[1]; + $sheet->getCell($firstCell); + } + + $validation->setSqref($cell); + $stRange = $sheet->shrinkRangeToFit($cell); + $cells = array_merge($cells, Coordinate::extractAllCellReferencesInRange($stRange)); + } + + break; + case 'Type': + $validation->setType(self::TYPE_MAPPINGS[$tagValueLower] ?? $tagValueLower); + + break; + case 'Qualifier': + $validation->setOperator(self::OPERATOR_MAPPINGS[$tagValueLower] ?? $tagValueLower); + + break; + case 'InputTitle': + $validation->setPromptTitle($tagValue); + + break; + case 'InputMessage': + $validation->setPrompt($tagValue); + + break; + case 'InputHide': + $validation->setShowInputMessage(false); + + break; + case 'ErrorStyle': + $validation->setErrorStyle($tagValueLower); + + break; + case 'ErrorTitle': + $validation->setErrorTitle($tagValue); + + break; + case 'ErrorMessage': + $validation->setError($tagValue); + + break; + case 'ErrorHide': + $validation->setShowErrorMessage(false); + + break; + case 'ComboHide': + $validation->setShowDropDown(false); + + break; + case 'UseBlank': + $validation->setAllowBlank(true); + + break; + case 'CellRangeList': + // FIXME missing FIXME + + break; + case 'Min': + case 'Value': + $tagValue = (string) preg_replace_callback(AddressHelper::R1C1_COORDINATE_REGEX, $pregCallback, $tagValue); + $validation->setFormula1($tagValue); + + break; + case 'Max': + $tagValue = (string) preg_replace_callback(AddressHelper::R1C1_COORDINATE_REGEX, $pregCallback, $tagValue); + $validation->setFormula2($tagValue); + + break; + } + } + + foreach ($cells as $cell) { + $sheet->getCell($cell)->setDataValidation(clone $validation); + } + } + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Date.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Date.php new file mode 100644 index 0000000..61ac117 --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Date.php @@ -0,0 +1,125 @@ +separators = $this->padSeparatorArray( + is_array($separators) ? $separators : [$separators], + count($formatBlocks) - 1 + ); + $this->formatBlocks = array_map([$this, 'mapFormatBlocks'], $formatBlocks); + } + + private function mapFormatBlocks(string $value): string + { + // Any date masking codes are returned as lower case values + if (in_array(mb_strtolower($value), self::DATE_BLOCKS, true)) { + return mb_strtolower($value); + } + + // Wrap any string literals in quotes, so that they're clearly defined as string literals + return $this->wrapLiteral($value); + } + + public function format(): string + { + return implode('', array_map([$this, 'intersperse'], $this->formatBlocks, $this->separators)); + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php new file mode 100644 index 0000000..292c1ef --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php @@ -0,0 +1,50 @@ + + */ + protected array $formatBlocks; + + /** + * @param null|string|string[] $separators + * If you want to use only a single format block, then pass a null as the separator argument + * @param DateTimeWizard|string ...$formatBlocks + */ + public function __construct($separators, ...$formatBlocks) + { + $this->separators = $this->padSeparatorArray( + is_array($separators) ? $separators : [$separators], + count($formatBlocks) - 1 + ); + $this->formatBlocks = array_map([$this, 'mapFormatBlocks'], $formatBlocks); + } + + /** + * @param DateTimeWizard|string $value + */ + private function mapFormatBlocks($value): string + { + // Any date masking codes are returned as lower case values + if (is_object($value)) { + // We can't explicitly test for Stringable until PHP >= 8.0 + return $value; + } + + // Wrap any string literals in quotes, so that they're clearly defined as string literals + return $this->wrapLiteral($value); + } + + public function format(): string + { + return implode('', array_map([$this, 'intersperse'], $this->formatBlocks, $this->separators)); + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTimeWizard.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTimeWizard.php new file mode 100644 index 0000000..b14a619 --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTimeWizard.php @@ -0,0 +1,44 @@ += "; + + protected function padSeparatorArray(array $separators, int $count): array + { + $lastSeparator = array_pop($separators); + + return $separators + array_fill(0, $count, $lastSeparator); + } + + protected function escapeSingleCharacter(string $value): string + { + if (strpos(self::NO_ESCAPING_NEEDED, $value) !== false) { + return $value; + } + + return "\\{$value}"; + } + + protected function wrapLiteral(string $value): string + { + if (mb_strlen($value, 'UTF-8') === 1) { + return $this->escapeSingleCharacter($value); + } + + // Wrap any other string literals in quotes, so that they're clearly defined as string literals + return '"' . str_replace('"', '""', $value) . '"'; + } + + protected function intersperse(string $formatBlock, ?string $separator): string + { + return "{$formatBlock}{$separator}"; + } + + public function __toString(): string + { + return $this->format(); + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Duration.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Duration.php new file mode 100644 index 0000000..b81f77a --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Duration.php @@ -0,0 +1,153 @@ + self::DAYS_DURATION, + self::HOURS_DURATION => self::HOURS_SHORT, + self::MINUTES_DURATION => self::MINUTES_LONG, + self::SECONDS_DURATION => self::SECONDS_LONG, + ]; + + protected const DURATION_DEFAULTS = [ + self::HOURS_LONG => self::HOURS_DURATION, + self::HOURS_SHORT => self::HOURS_DURATION, + self::MINUTES_LONG => self::MINUTES_DURATION, + self::MINUTES_SHORT => self::MINUTES_DURATION, + self::SECONDS_LONG => self::SECONDS_DURATION, + self::SECONDS_SHORT => self::SECONDS_DURATION, + ]; + + public const SEPARATOR_COLON = ':'; + public const SEPARATOR_SPACE_NONBREAKING = "\u{a0}"; + public const SEPARATOR_SPACE = ' '; + + public const DURATION_DEFAULT = [ + self::HOURS_DURATION, + self::MINUTES_LONG, + self::SECONDS_LONG, + ]; + + /** + * @var string[] + */ + protected array $separators; + + /** + * @var string[] + */ + protected array $formatBlocks; + + protected bool $durationIsSet = false; + + /** + * @param null|string|string[] $separators + * If you want to use the same separator for all format blocks, then it can be passed as a string literal; + * if you wish to use different separators, then they should be passed as an array. + * If you want to use only a single format block, then pass a null as the separator argument + */ + public function __construct($separators = self::SEPARATOR_COLON, string ...$formatBlocks) + { + $separators ??= self::SEPARATOR_COLON; + $formatBlocks = (count($formatBlocks) === 0) ? self::DURATION_DEFAULT : $formatBlocks; + + $this->separators = $this->padSeparatorArray( + is_array($separators) ? $separators : [$separators], + count($formatBlocks) - 1 + ); + $this->formatBlocks = array_map([$this, 'mapFormatBlocks'], $formatBlocks); + + if ($this->durationIsSet === false) { + // We need at least one duration mask, so if none has been set we change the first mask element + // to a duration. + $this->formatBlocks[0] = self::DURATION_DEFAULTS[mb_strtolower($this->formatBlocks[0])]; + } + } + + private function mapFormatBlocks(string $value): string + { + // Any duration masking codes are returned as lower case values + if (in_array(mb_strtolower($value), self::DURATION_BLOCKS, true)) { + if (array_key_exists(mb_strtolower($value), self::DURATION_MASKS)) { + if ($this->durationIsSet) { + // We should only have a single duration mask, the first defined in the mask set, + // so convert any additional duration masks to standard time masks. + $value = self::DURATION_MASKS[mb_strtolower($value)]; + } + $this->durationIsSet = true; + } + + return mb_strtolower($value); + } + + // Wrap any string literals in quotes, so that they're clearly defined as string literals + return $this->wrapLiteral($value); + } + + public function format(): string + { + return implode('', array_map([$this, 'intersperse'], $this->formatBlocks, $this->separators)); + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Time.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Time.php new file mode 100644 index 0000000..64b9104 --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Time.php @@ -0,0 +1,105 @@ +separators = $this->padSeparatorArray( + is_array($separators) ? $separators : [$separators], + count($formatBlocks) - 1 + ); + $this->formatBlocks = array_map([$this, 'mapFormatBlocks'], $formatBlocks); + } + + private function mapFormatBlocks(string $value): string + { + // Any date masking codes are returned as lower case values + // except for AM/PM, which is set to uppercase + if (in_array(mb_strtolower($value), self::TIME_BLOCKS, true)) { + return mb_strtolower($value); + } elseif (mb_strtoupper($value) === self::MORNING_AFTERNOON) { + return mb_strtoupper($value); + } + + // Wrap any string literals in quotes, so that they're clearly defined as string literals + return $this->wrapLiteral($value); + } + + public function format(): string + { + return implode('', array_map([$this, 'intersperse'], $this->formatBlocks, $this->separators)); + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/RgbTint.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/RgbTint.php new file mode 100644 index 0000000..582ae48 --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/RgbTint.php @@ -0,0 +1,175 @@ += 0.0) ? $hue : (1.0 + $hue); + } + + /** + * Convert red/green/blue to HLSMAX-based hue/luminance/saturation. + * + * @return int[] + */ + private static function rgbToMsHls(int $red, int $green, int $blue): array + { + $red01 = $red / self::RGBMAX; + $green01 = $green / self::RGBMAX; + $blue01 = $blue / self::RGBMAX; + [$hue, $luminance, $saturation] = self::rgbToHls($red01, $green01, $blue01); + + return [ + (int) round($hue * self::HLSMAX), + (int) round($luminance * self::HLSMAX), + (int) round($saturation * self::HLSMAX), + ]; + } + + /** + * Converts HLSMAX based HLS values to rgb values in the range (0,1). + * + * @return float[] + */ + private static function msHlsToRgb(int $hue, int $lightness, int $saturation): array + { + return self::hlsToRgb($hue / self::HLSMAX, $lightness / self::HLSMAX, $saturation / self::HLSMAX); + } + + /** + * Tints HLSMAX based luminance. + * + * @see http://ciintelligence.blogspot.co.uk/2012/02/converting-excel-theme-color-and-tint.html + */ + private static function tintLuminance(float $tint, float $luminance): int + { + if ($tint < 0) { + return (int) round($luminance * (1.0 + $tint)); + } + + return (int) round($luminance * (1.0 - $tint) + (self::HLSMAX - self::HLSMAX * (1.0 - $tint))); + } + + /** + * Return result of tinting supplied rgb as 6 hex digits. + */ + public static function rgbAndTintToRgb(int $red, int $green, int $blue, float $tint): string + { + [$hue, $luminance, $saturation] = self::rgbToMsHls($red, $green, $blue); + [$red, $green, $blue] = self::msHlsToRgb($hue, self::tintLuminance($tint, $luminance), $saturation); + + return sprintf( + '%02X%02X%02X', + (int) round($red * self::RGBMAX), + (int) round($green * self::RGBMAX), + (int) round($blue * self::RGBMAX) + ); + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Theme.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Theme.php new file mode 100644 index 0000000..ab101f0 --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Theme.php @@ -0,0 +1,269 @@ + '000000', + 'lt1' => 'FFFFFF', + 'dk2' => '44546A', + 'lt2' => 'E7E6E6', + 'accent1' => '4472C4', + 'accent2' => 'ED7D31', + 'accent3' => 'A5A5A5', + 'accent4' => 'FFC000', + 'accent5' => '5B9BD5', + 'accent6' => '70AD47', + 'hlink' => '0563C1', + 'folHlink' => '954F72', + ]; + + public const COLOR_SCHEME_2007_2010_NAME = 'Office 2007-2010'; + public const COLOR_SCHEME_2007_2010 = [ + 'dk1' => '000000', + 'lt1' => 'FFFFFF', + 'dk2' => '1F497D', + 'lt2' => 'EEECE1', + 'accent1' => '4F81BD', + 'accent2' => 'C0504D', + 'accent3' => '9BBB59', + 'accent4' => '8064A2', + 'accent5' => '4BACC6', + 'accent6' => 'F79646', + 'hlink' => '0000FF', + 'folHlink' => '800080', + ]; + + /** @var string[] */ + private $themeColors = self::COLOR_SCHEME_2007_2010; + + /** @var string */ + private $majorFontLatin = 'Cambria'; + + /** @var string */ + private $majorFontEastAsian = ''; + + /** @var string */ + private $majorFontComplexScript = ''; + + /** @var string */ + private $minorFontLatin = 'Calibri'; + + /** @var string */ + private $minorFontEastAsian = ''; + + /** @var string */ + private $minorFontComplexScript = ''; + + /** + * Map of Major (header) fonts to write. + * + * @var string[] + */ + private $majorFontSubstitutions = self::FONTS_TIMES_SUBSTITUTIONS; + + /** + * Map of Minor (body) fonts to write. + * + * @var string[] + */ + private $minorFontSubstitutions = self::FONTS_ARIAL_SUBSTITUTIONS; + + public const FONTS_TIMES_SUBSTITUTIONS = [ + 'Jpan' => 'MS Pゴシック', + 'Hang' => '맑은 고딕', + 'Hans' => '宋体', + 'Hant' => '新細明體', + 'Arab' => 'Times New Roman', + 'Hebr' => 'Times New Roman', + 'Thai' => 'Tahoma', + 'Ethi' => 'Nyala', + 'Beng' => 'Vrinda', + 'Gujr' => 'Shruti', + 'Khmr' => 'MoolBoran', + 'Knda' => 'Tunga', + 'Guru' => 'Raavi', + 'Cans' => 'Euphemia', + 'Cher' => 'Plantagenet Cherokee', + 'Yiii' => 'Microsoft Yi Baiti', + 'Tibt' => 'Microsoft Himalaya', + 'Thaa' => 'MV Boli', + 'Deva' => 'Mangal', + 'Telu' => 'Gautami', + 'Taml' => 'Latha', + 'Syrc' => 'Estrangelo Edessa', + 'Orya' => 'Kalinga', + 'Mlym' => 'Kartika', + 'Laoo' => 'DokChampa', + 'Sinh' => 'Iskoola Pota', + 'Mong' => 'Mongolian Baiti', + 'Viet' => 'Times New Roman', + 'Uigh' => 'Microsoft Uighur', + 'Geor' => 'Sylfaen', + ]; + + public const FONTS_ARIAL_SUBSTITUTIONS = [ + 'Jpan' => 'MS Pゴシック', + 'Hang' => '맑은 고딕', + 'Hans' => '宋体', + 'Hant' => '新細明體', + 'Arab' => 'Arial', + 'Hebr' => 'Arial', + 'Thai' => 'Tahoma', + 'Ethi' => 'Nyala', + 'Beng' => 'Vrinda', + 'Gujr' => 'Shruti', + 'Khmr' => 'DaunPenh', + 'Knda' => 'Tunga', + 'Guru' => 'Raavi', + 'Cans' => 'Euphemia', + 'Cher' => 'Plantagenet Cherokee', + 'Yiii' => 'Microsoft Yi Baiti', + 'Tibt' => 'Microsoft Himalaya', + 'Thaa' => 'MV Boli', + 'Deva' => 'Mangal', + 'Telu' => 'Gautami', + 'Taml' => 'Latha', + 'Syrc' => 'Estrangelo Edessa', + 'Orya' => 'Kalinga', + 'Mlym' => 'Kartika', + 'Laoo' => 'DokChampa', + 'Sinh' => 'Iskoola Pota', + 'Mong' => 'Mongolian Baiti', + 'Viet' => 'Arial', + 'Uigh' => 'Microsoft Uighur', + 'Geor' => 'Sylfaen', + ]; + + public function getThemeColors(): array + { + return $this->themeColors; + } + + public function setThemeColor(string $key, string $value): self + { + $this->themeColors[$key] = $value; + + return $this; + } + + public function getThemeColorName(): string + { + return $this->themeColorName; + } + + public function setThemeColorName(string $name, ?array $themeColors = null): self + { + $this->themeColorName = $name; + if ($name === self::COLOR_SCHEME_2007_2010_NAME) { + $themeColors = $themeColors ?? self::COLOR_SCHEME_2007_2010; + } elseif ($name === self::COLOR_SCHEME_2013_PLUS_NAME) { + $themeColors = $themeColors ?? self::COLOR_SCHEME_2013_PLUS; + } + if ($themeColors !== null) { + $this->themeColors = $themeColors; + } + + return $this; + } + + public function getMajorFontLatin(): string + { + return $this->majorFontLatin; + } + + public function getMajorFontEastAsian(): string + { + return $this->majorFontEastAsian; + } + + public function getMajorFontComplexScript(): string + { + return $this->majorFontComplexScript; + } + + public function getMajorFontSubstitutions(): array + { + return $this->majorFontSubstitutions; + } + + /** @param null|array $substitutions */ + public function setMajorFontValues(?string $latin, ?string $eastAsian, ?string $complexScript, $substitutions): self + { + if (!empty($latin)) { + $this->majorFontLatin = $latin; + } + if ($eastAsian !== null) { + $this->majorFontEastAsian = $eastAsian; + } + if ($complexScript !== null) { + $this->majorFontComplexScript = $complexScript; + } + if ($substitutions !== null) { + $this->majorFontSubstitutions = $substitutions; + } + + return $this; + } + + public function getMinorFontLatin(): string + { + return $this->minorFontLatin; + } + + public function getMinorFontEastAsian(): string + { + return $this->minorFontEastAsian; + } + + public function getMinorFontComplexScript(): string + { + return $this->minorFontComplexScript; + } + + public function getMinorFontSubstitutions(): array + { + return $this->minorFontSubstitutions; + } + + /** @param null|array $substitutions */ + public function setMinorFontValues(?string $latin, ?string $eastAsian, ?string $complexScript, $substitutions): self + { + if (!empty($latin)) { + $this->minorFontLatin = $latin; + } + if ($eastAsian !== null) { + $this->minorFontEastAsian = $eastAsian; + } + if ($complexScript !== null) { + $this->minorFontComplexScript = $complexScript; + } + if ($substitutions !== null) { + $this->minorFontSubstitutions = $substitutions; + } + + return $this; + } + + public function getThemeFontName(): string + { + return $this->themeFontName; + } + + public function setThemeFontName(?string $name): self + { + if (!empty($name)) { + $this->themeFontName = $name; + } + + return $this; + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream0.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream0.php new file mode 100644 index 0000000..886731c --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream0.php @@ -0,0 +1,17 @@ +setEnableZip64(false); + $options->setOutputStream($fileHandle); + + return new ZipStream(null, $options); + } +} diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream3.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream3.php new file mode 100644 index 0000000..d9c8d0b --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream3.php @@ -0,0 +1,22 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +$local_path = "/data/exampleobject"; +try { + // -------------------- 1. 人体识别 原图存储在COS -------------------- // + $result = $cosClient->aIBodyRecognitionProcess(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'test.jpg', + )); + // 请求成功 + print_r($result); + // -------------------- 1. 人体识别 原图存储在COS -------------------- // + + // -------------------- 2. 人体识别 原图来自其他链接 -------------------- // + $result = $cosClient->aIBodyRecognitionProcess(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // 该值为空即可 + 'DetectUrl' => 'https://www.xxx.com/xxx.jpg', + )); + // 请求成功 + print_r($result); + // -------------------- 2. 人体识别 原图来自其他链接 -------------------- // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/aIGameRecProcess.php b/vendor/qcloud/cos-sdk-v5/sample/aIGameRecProcess.php new file mode 100644 index 0000000..9dbed7c --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/aIGameRecProcess.php @@ -0,0 +1,38 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +$local_path = "/data/exampleobject"; +try { + // -------------------- 1. 游戏场景识别 原图存储在COS -------------------- // + $result = $cosClient->aIGameRecProcess(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'test.jpg', + )); + // 请求成功 + print_r($result); + // -------------------- 1. 游戏场景识别 原图存储在COS -------------------- // + + // -------------------- 2. 游戏场景识别 原图来自其他链接 -------------------- // + $result = $cosClient->aIGameRecProcess(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // 该值为空即可 + 'DetectUrl' => 'https://www.xxx.com/xxx.jpg', + )); + // 请求成功 + print_r($result); + // -------------------- 2. 游戏场景识别 原图来自其他链接 -------------------- // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/aIImageColoringProcess.php b/vendor/qcloud/cos-sdk-v5/sample/aIImageColoringProcess.php new file mode 100644 index 0000000..684f972 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/aIImageColoringProcess.php @@ -0,0 +1,65 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // -------------------- 1. 下载时处理-原图存储在COS -------------------- // + $object = 'xxx.jpg'; + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AIImageColoring'); + $query = $ciProcessParams->queryString(); + $downloadUrl = $cosClient->getObjectUrl('examplebucket-1250000000', $object); // 获取下载链接 + echo "{$downloadUrl}&{$query}"; // 携带签名的图片地址以“&”连接 + // -------------------- 1. 下载时处理-原图存储在COS -------------------- // + + // -------------------- 2. 下载时处理-原图来自其他链接 -------------------- // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AIImageColoring'); + $ciProcessParams->addParam('detect-url', 'https://xxx.com/xxx.jpg'); + $query = $ciProcessParams->queryString(); + $downloadUrl = $cosClient->getObjectUrl('examplebucket-1250000000', ''); // 获取下载链接 + echo "{$downloadUrl}&{$query}"; + // -------------------- 2. 下载时处理-原图来自其他链接 -------------------- // + + // ---------------------------- 3. 上传时处理 ---------------------------- // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AIImageColoring'); + + $picOperations = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation(); + $picOperations->setIsPicInfo(1); // is_pic_info + $picOperations->addRule($ciProcessParams, "output.png"); // rules + $result = $cosClient->putObject(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'object.jpg', + 'Body' => fopen('/tmp/local.jpg', 'rb'), // 本地文件 + 'PicOperations' => $picOperations->queryString(), + )); + // 请求成功 + print_r($result); + // ---------------------------- 3. 上传时处理 ---------------------------- // + + // --------------------- 4. 云上数据处理 ------------------------------ // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AIImageColoring'); + + $picOperations = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation(); + $picOperations->setIsPicInfo(1); // is_pic_info + $picOperations->addRule($ciProcessParams, 'output.jpg'); // rules + $result = $cosClient->ImageProcess(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'test.jpg', + 'PicOperations' => $picOperations->queryString(), + )); + // 请求成功 + print_r($result); + // --------------------- 4. 云上数据处理 ------------------------------ // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/aIImageCropProcess.php b/vendor/qcloud/cos-sdk-v5/sample/aIImageCropProcess.php new file mode 100644 index 0000000..c68e2e4 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/aIImageCropProcess.php @@ -0,0 +1,83 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // -------------------- 1. 下载时处理-原图存储在COS -------------------- // + $object = 'xxx.jpg'; + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AIImageCrop'); + $ciProcessParams->addParam('width', 100); // 需要裁剪区域的宽度,与height共同组成所需裁剪的图片宽高比例;输入数字请大于0、小于图片宽度的像素值 + $ciProcessParams->addParam('height', 100); // 需要裁剪区域的高度,与width共同组成所需裁剪的图片宽高比例;输入数字请大于0、小于图片高度的像素值;width : height建议取值在[1, 2.5]之间,超过这个范围可能会影响效果 + $ciProcessParams->addParam('fixed', 0); // 是否严格按照 width 和 height 的值进行输出。 + $ciProcessParams->addParam('ignore-error', 1); // 当此参数为1时,针对文件过大等导致处理失败的场景,会直接返回原图而不报错。 + + $query = $ciProcessParams->queryString(); + $downloadUrl = $cosClient->getObjectUrl('examplebucket-1250000000', $object); // 获取下载链接 + echo "{$downloadUrl}&{$query}"; // 携带签名的图片地址以“&”连接 + // -------------------- 1. 下载时处理-原图存储在COS -------------------- // + + // -------------------- 2. 下载时处理-原图来自其他链接 -------------------- // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AIImageCrop'); + $ciProcessParams->addParam('detect-url', 'https://xxx.com/xxx.jpg'); + $ciProcessParams->addParam('width', 100); // 需要裁剪区域的宽度,与height共同组成所需裁剪的图片宽高比例;输入数字请大于0、小于图片宽度的像素值 + $ciProcessParams->addParam('height', 100); // 需要裁剪区域的高度,与width共同组成所需裁剪的图片宽高比例;输入数字请大于0、小于图片高度的像素值;width : height建议取值在[1, 2.5]之间,超过这个范围可能会影响效果 + $ciProcessParams->addParam('fixed', 0); // 是否严格按照 width 和 height 的值进行输出。 + $ciProcessParams->addParam('ignore-error', 1); // 当此参数为1时,针对文件过大等导致处理失败的场景,会直接返回原图而不报错。 + + $query = $ciProcessParams->queryString(); + $downloadUrl = $cosClient->getObjectUrl('examplebucket-1250000000', ''); // 获取下载链接 + echo "{$downloadUrl}&{$query}"; + // -------------------- 2. 下载时处理-原图来自其他链接 -------------------- // + + // ---------------------------- 3. 上传时处理 ---------------------------- // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AIImageCrop'); + $ciProcessParams->addParam('width', 100); // 需要裁剪区域的宽度,与height共同组成所需裁剪的图片宽高比例;输入数字请大于0、小于图片宽度的像素值 + $ciProcessParams->addParam('height', 100); // 需要裁剪区域的高度,与width共同组成所需裁剪的图片宽高比例;输入数字请大于0、小于图片高度的像素值;width : height建议取值在[1, 2.5]之间,超过这个范围可能会影响效果 + $ciProcessParams->addParam('fixed', 0); // 是否严格按照 width 和 height 的值进行输出。 + $ciProcessParams->addParam('ignore-error', 1); // 当此参数为1时,针对文件过大等导致处理失败的场景,会直接返回原图而不报错。 + + $picOperations = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation(); + $picOperations->setIsPicInfo(1); // is_pic_info + $picOperations->addRule($ciProcessParams, "output.png"); // rules + $result = $cosClient->putObject(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'object.jpg', + 'Body' => fopen('/tmp/local.jpg', 'rb'), // 本地文件 + 'PicOperations' => $picOperations->queryString(), + )); + // 请求成功 + print_r($result); + // ---------------------------- 3. 上传时处理 ---------------------------- // + + // --------------------- 4. 云上数据处理 ------------------------------ // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AIImageCrop'); + $ciProcessParams->addParam('width', 100); // 需要裁剪区域的宽度,与height共同组成所需裁剪的图片宽高比例;输入数字请大于0、小于图片宽度的像素值 + $ciProcessParams->addParam('height', 100); // 需要裁剪区域的高度,与width共同组成所需裁剪的图片宽高比例;输入数字请大于0、小于图片高度的像素值;width : height建议取值在[1, 2.5]之间,超过这个范围可能会影响效果 + $ciProcessParams->addParam('fixed', 0); // 是否严格按照 width 和 height 的值进行输出。 + $ciProcessParams->addParam('ignore-error', 1); // 当此参数为1时,针对文件过大等导致处理失败的场景,会直接返回原图而不报错。 + + $picOperations = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation(); + $picOperations->setIsPicInfo(1); // is_pic_info + $picOperations->addRule($ciProcessParams, 'output.jpg'); // rules + $result = $cosClient->ImageProcess(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'test.jpg', + 'PicOperations' => $picOperations->queryString(), + )); + // 请求成功 + print_r($result); + // --------------------- 4. 云上数据处理 ------------------------------ // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/aIImageEnhanceProcess.php b/vendor/qcloud/cos-sdk-v5/sample/aIImageEnhanceProcess.php new file mode 100644 index 0000000..58bfd04 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/aIImageEnhanceProcess.php @@ -0,0 +1,79 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // -------------------- 1. 下载时处理-原图存储在COS -------------------- // + $object = 'xxx.jpg'; + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AIEnhanceImage'); + $ciProcessParams->addParam('denoise', 3); // 去噪强度值,取值范围为 0 - 5 之间的整数,值为 0 时不进行去噪操作,默认值为3。 + $ciProcessParams->addParam('sharpen', 3); // 锐化强度值,取值范围为 0 - 5 之间的整数,值为 0 时不进行锐化操作,默认值为3。 + $ciProcessParams->addParam('ignore-error', 1); // 当此参数为1时,针对文件过大等导致处理失败的场景,会直接返回原图而不报错。 + + $query = $ciProcessParams->queryString(); + $downloadUrl = $cosClient->getObjectUrl('examplebucket-1250000000', $object); // 获取下载链接 + echo "{$downloadUrl}&{$query}"; // 携带签名的图片地址以“&”连接 + // -------------------- 1. 下载时处理-原图存储在COS -------------------- // + + // -------------------- 2. 下载时处理-原图来自其他链接 -------------------- // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AIEnhanceImage'); + $ciProcessParams->addParam('detect-url', 'https://xxx.com/xxx.jpg'); + $ciProcessParams->addParam('denoise', 3); // 去噪强度值,取值范围为 0 - 5 之间的整数,值为 0 时不进行去噪操作,默认值为3。 + $ciProcessParams->addParam('sharpen', 3); // 锐化强度值,取值范围为 0 - 5 之间的整数,值为 0 时不进行锐化操作,默认值为3。 + $ciProcessParams->addParam('ignore-error', 1); // 当此参数为1时,针对文件过大等导致处理失败的场景,会直接返回原图而不报错。 + + $query = $ciProcessParams->queryString(); + $downloadUrl = $cosClient->getObjectUrl('examplebucket-1250000000', ''); // 获取下载链接 + echo "{$downloadUrl}&{$query}"; + // -------------------- 2. 下载时处理-原图来自其他链接 -------------------- // + + // ---------------------------- 3. 上传时处理 ---------------------------- // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AIEnhanceImage'); + $ciProcessParams->addParam('denoise', 3); // 去噪强度值,取值范围为 0 - 5 之间的整数,值为 0 时不进行去噪操作,默认值为3。 + $ciProcessParams->addParam('sharpen', 3); // 锐化强度值,取值范围为 0 - 5 之间的整数,值为 0 时不进行锐化操作,默认值为3。 + $ciProcessParams->addParam('ignore-error', 1); // 当此参数为1时,针对文件过大等导致处理失败的场景,会直接返回原图而不报错。 + + $picOperations = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation(); + $picOperations->setIsPicInfo(1); // is_pic_info + $picOperations->addRule($ciProcessParams, "output.png"); // rules + $result = $cosClient->putObject(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'object.jpg', + 'Body' => fopen('/tmp/local.jpg', 'rb'), // 本地文件 + 'PicOperations' => $picOperations->queryString(), + )); + // 请求成功 + print_r($result); + // ---------------------------- 3. 上传时处理 ---------------------------- // + + // --------------------- 4. 云上数据处理 ------------------------------ // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AIEnhanceImage'); + $ciProcessParams->addParam('denoise', 3); // 去噪强度值,取值范围为 0 - 5 之间的整数,值为 0 时不进行去噪操作,默认值为3。 + $ciProcessParams->addParam('sharpen', 3); // 锐化强度值,取值范围为 0 - 5 之间的整数,值为 0 时不进行锐化操作,默认值为3。 + $ciProcessParams->addParam('ignore-error', 1); // 当此参数为1时,针对文件过大等导致处理失败的场景,会直接返回原图而不报错。 + + $picOperations = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation(); + $picOperations->setIsPicInfo(1); // is_pic_info + $picOperations->addRule($ciProcessParams, 'output.jpg'); // rules + $result = $cosClient->ImageProcess(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'test.jpg', + 'PicOperations' => $picOperations->queryString(), + )); + // 请求成功 + print_r($result); + // --------------------- 4. 云上数据处理 ------------------------------ // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/aIImageSuperResolutionProcess.php b/vendor/qcloud/cos-sdk-v5/sample/aIImageSuperResolutionProcess.php new file mode 100644 index 0000000..6079187 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/aIImageSuperResolutionProcess.php @@ -0,0 +1,65 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // -------------------- 1. 下载时处理-原图存储在COS -------------------- // + $object = 'xxx.jpg'; + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AISuperResolution'); + $query = $ciProcessParams->queryString(); + $downloadUrl = $cosClient->getObjectUrl('examplebucket-1250000000', $object); // 获取下载链接 + echo "{$downloadUrl}&{$query}"; // 携带签名的图片地址以“&”连接 + // -------------------- 1. 下载时处理-原图存储在COS -------------------- // + + // -------------------- 2. 下载时处理-原图来自其他链接 -------------------- // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AISuperResolution'); + $ciProcessParams->addParam('detect-url', 'https://xxx.com/xxx.jpg'); + $query = $ciProcessParams->queryString(); + $downloadUrl = $cosClient->getObjectUrl('examplebucket-1250000000', ''); // 获取下载链接 + echo "{$downloadUrl}&{$query}"; + // -------------------- 2. 下载时处理-原图来自其他链接 -------------------- // + + // ---------------------------- 3. 上传时处理 ---------------------------- // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AISuperResolution'); + + $picOperations = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation(); + $picOperations->setIsPicInfo(1); // is_pic_info + $picOperations->addRule($ciProcessParams, "output.png"); // rules + $result = $cosClient->putObject(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'object.jpg', + 'Body' => fopen('/tmp/local.jpg', 'rb'), // 本地文件 + 'PicOperations' => $picOperations->queryString(), + )); + // 请求成功 + print_r($result); + // ---------------------------- 3. 上传时处理 ---------------------------- // + + // --------------------- 4. 云上数据处理 ------------------------------ // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('AISuperResolution'); + + $picOperations = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation(); + $picOperations->setIsPicInfo(1); // is_pic_info + $picOperations->addRule($ciProcessParams, 'output.jpg'); // rules + $result = $cosClient->ImageProcess(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'test.jpg', + 'PicOperations' => $picOperations->queryString(), + )); + // 请求成功 + print_r($result); + // --------------------- 4. 云上数据处理 ------------------------------ // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/aILicenseRecProcess.php b/vendor/qcloud/cos-sdk-v5/sample/aILicenseRecProcess.php new file mode 100644 index 0000000..142465c --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/aILicenseRecProcess.php @@ -0,0 +1,40 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +$local_path = "/data/exampleobject"; +try { + // -------------------- 1. 卡证识别 原图存储在COS -------------------- // + $result = $cosClient->aILicenseRecProcess(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'test.jpg', + 'CardType' => 'IDCard', // 卡证识别类型,有效值为IDCard,DriverLicense。
IDCard表示身份证;DriverLicense表示驾驶证,默认:DriverLicense + )); + // 请求成功 + print_r($result); + // -------------------- 1. 卡证识别 原图存储在COS -------------------- // + + // -------------------- 2. 卡证识别 原图来自其他链接 暂不支持 -------------------- // + $result = $cosClient->aILicenseRecProcess(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // 该值为空即可 + 'DetectUrl' => 'https://www.xxx.com/xxx.jpg', + 'CardType' => 'IDCard', // 卡证识别类型,有效值为IDCard,DriverLicense。
IDCard表示身份证;DriverLicense表示驾驶证,默认:DriverLicense + )); + // 请求成功 + print_r($result); + // -------------------- 2. 卡证识别 原图来自其他链接 暂不支持 -------------------- // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/autoTranslationBlockProcess.php b/vendor/qcloud/cos-sdk-v5/sample/autoTranslationBlockProcess.php new file mode 100644 index 0000000..27238ac --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/autoTranslationBlockProcess.php @@ -0,0 +1,29 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 实时文字翻译 + $result = $cosClient->autoTranslationBlockProcess(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'InputText' => '', // 待翻译的文本 + 'SourceLang' => '', // 输入语言,如 "zh" + 'TargetLang' => '', // 输出语言,如 "en" +// 'TextDomain' => '', // 文本所属业务领域,如: "ecommerce", //缺省值为 general +// 'TextStyle' => '', // 文本类型,如: "title", //缺省值为 sentence + )); + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/closeAiService.php b/vendor/qcloud/cos-sdk-v5/sample/closeAiService.php new file mode 100644 index 0000000..098b678 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/closeAiService.php @@ -0,0 +1,24 @@ + $region, + 'scheme' => 'https', // 万象接口必须用https + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 关闭AI内容识别服务 + $result = $cosClient->closeAiService(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + )); + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/closeAsrService.php b/vendor/qcloud/cos-sdk-v5/sample/closeAsrService.php new file mode 100644 index 0000000..7250337 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/closeAsrService.php @@ -0,0 +1,24 @@ + $region, + 'scheme' => 'https', // 万象接口必须用https + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 关闭智能语音服务 https://cloud.tencent.com/document/product/460/95755 + $result = $cosClient->closeAsrService(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + )); + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/closeImageSlim.php b/vendor/qcloud/cos-sdk-v5/sample/closeImageSlim.php new file mode 100644 index 0000000..e312ef3 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/closeImageSlim.php @@ -0,0 +1,23 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + $result = $cosClient->closeImageSlim(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + )); + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createAiTranslationJobs.php b/vendor/qcloud/cos-sdk-v5/sample/createAiTranslationJobs.php new file mode 100644 index 0000000..8eac363 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createAiTranslationJobs.php @@ -0,0 +1,54 @@ + $region, + 'scheme' => 'https', // 万象接口必须使用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 提交一个翻译任务 https://cloud.tencent.com/document/product/460/84799 + $result = $cosClient->createAiTranslationJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'Translation', + 'Input' => array( + 'Object' => 'test.docx', + 'Lang' => 'zh', + 'Type' => 'docx', +// 'BasicType' => '', + ), + 'Operation' => array( +// 'UserData' => 'xxx', +// 'JobLevel' => '', +// 'NoNeedOutput' => 'true', + 'Translation' => array( + 'Lang' => 'en', + 'Type' => 'docx', + ), + 'Output' => array( + 'Region' => $region, + 'Bucket' => 'examplebucket-125000000', + 'Object' => 'xxx.txt', + ), + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createAiWordsGeneralizeJobs.php b/vendor/qcloud/cos-sdk-v5/sample/createAiWordsGeneralizeJobs.php new file mode 100644 index 0000000..174d0f0 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createAiWordsGeneralizeJobs.php @@ -0,0 +1,45 @@ + $region, + 'scheme' => 'https', // 万象接口必须使用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 提交一个分词任务 https://cloud.tencent.com/document/product/460/84800 + $result = $cosClient->createAiWordsGeneralizeJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'WordsGeneralize', + 'Input' => array( + 'Object' => 'test.txt', + ), + 'Operation' => array( +// 'UserData' => '', +// 'JobLevel' => '', + 'WordsGeneralize' => array( + 'NerMethod' => 'DL', + 'SegMethod' => 'MIX', + ), + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createM3U8PlayListJobs.php b/vendor/qcloud/cos-sdk-v5/sample/createM3U8PlayListJobs.php new file mode 100644 index 0000000..508ab74 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createM3U8PlayListJobs.php @@ -0,0 +1,45 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + $result = $cosClient->createM3U8PlayListJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'StartTime' => 1679386006, + 'EndTime' => 1679386006, + 'Operation' => array( + 'M3U8List' => array( + array( + 'BucketId' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Index' => '0', + 'ObjectPath' => 'test1.m3u8', + ), + array( + 'BucketId' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Index' => '0', + 'ObjectPath' => 'test2.m3u8', + ), + ), + 'Output' => array( + 'Region' => $region, + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Object' => 'xxx.m3u8', + ), + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createMediaNoiseReductionTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/createMediaNoiseReductionTemplate.php new file mode 100644 index 0000000..ecc7bc8 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createMediaNoiseReductionTemplate.php @@ -0,0 +1,31 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 创建音频降噪模板 https://cloud.tencent.com/document/product/460/94315 + $result = $cosClient->createMediaNoiseReductionTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'NoiseReduction', + 'Name' => 'NoiseReduction-Template', + 'NoiseReduction' => array( + 'Format' => 'wav', + 'Samplerate' => '16000', + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createMediaSegmentVideoBodyJobs.php b/vendor/qcloud/cos-sdk-v5/sample/createMediaSegmentVideoBodyJobs.php new file mode 100644 index 0000000..bd39ca5 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createMediaSegmentVideoBodyJobs.php @@ -0,0 +1,90 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 提交视频人像抠图任务 + // start --------------- 使用模版 暂不支持模版ID ----------------- // + $result = $cosClient->createMediaSegmentVideoBodyJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'SegmentVideoBody', + 'Input' => array( + 'Object' => 'input/test.mp4', + ), + 'Operation' => array( + 'TemplateId' => '', + 'Output' => array( + 'Region' => $region, + 'Bucket' => 'examplebucket-125000000', + 'Object' => 'output/out.mp4', + ), +// 'UserData' => '', +// 'JobLevel' => '', + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); + // end --------------- 使用模版 ----------------- // + + + // start --------------- 自定义参数 ----------------- // + $result = $cosClient->createMediaSegmentVideoBodyJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'SegmentVideoBody', + 'Input' => array( + 'Object' => 'input/test.mp4', + ), + 'Operation' => array( + 'SegmentVideoBody' => array( + 'Mode' => 'Mask', + 'SegmentType' => '', + 'BackgroundGreen' => '', + 'BackgroundBlue' => '', + 'BackgroundLogoUrl' => '', + 'BinaryThreshold' => '', + 'RemoveRed' => '', + 'RemoveGreen' => '', + 'RemoveBlue' => '', + ), + 'Output' => array( + 'Region' => $region, + 'Bucket' => 'examplebucket-125000000', + 'Object' => 'output/out.mp4', + ), +// 'UserData' => '', +// 'JobLevel' => '', + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); + // end --------------- 自定义参数 ----------------- // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createMediaSmartCoverTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/createMediaSmartCoverTemplate.php new file mode 100644 index 0000000..2a976c3 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createMediaSmartCoverTemplate.php @@ -0,0 +1,34 @@ + $region, + 'scheme' => 'https', // 万象接口必须使用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 创建智能封面模板 https://cloud.tencent.com/document/product/460/84734 + $result = $cosClient->createMediaSmartCoverTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'SmartCover', + 'Name' => 'media-smartcover-name', + 'SmartCover' => array( + 'Format' => 'jpg', + 'Width' => '1280', + 'Height' => '960', + 'Count' => '3', + 'DeleteDuplicates' => 'true', + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createMediaTargetRecJobs.php b/vendor/qcloud/cos-sdk-v5/sample/createMediaTargetRecJobs.php new file mode 100644 index 0000000..d1ac8bb --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createMediaTargetRecJobs.php @@ -0,0 +1,74 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 提交视频目标检测任务 + // start --------------- 使用模版 ----------------- // + $result = $cosClient->createMediaTargetRecJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'VideoTargetRec', + 'Input' => array( + 'Object' => 'test.mp4', + ), + 'Operation' => array( + 'TemplateId' => '', +// 'UserData' => 'xxx', +// 'JobLevel' => '0', + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); + // end --------------- 使用模版 ----------------- // + + + // start --------------- 自定义参数 ----------------- // + $result = $cosClient->createMediaTargetRecJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'VideoTargetRec', + 'Input' => array( + 'Object' => 'test.mp4', + ), + 'Operation' => array( +// 'UserData' => 'xxx', +// 'JobLevel' => '0', + 'VideoTargetRec' => array( + 'Body' => 'true', + 'Pet' => 'true', + 'Car' => 'false', + ), + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); + // end --------------- 自定义参数 ----------------- // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createMediaTargetRecTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/createMediaTargetRecTemplate.php new file mode 100644 index 0000000..ada61db --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createMediaTargetRecTemplate.php @@ -0,0 +1,32 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 创建视频目标检测模板 + $result = $cosClient->createMediaTargetRecTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'VideoTargetRec', + 'Name' => 'template-name', + 'VideoTargetRec' => array( + 'Body' => 'true', + 'Pet' => 'true', + 'Car' => 'false', + ), // Body、Pet、Car 不能同时为 false + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createMediaTranscodeProTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/createMediaTranscodeProTemplate.php new file mode 100644 index 0000000..bb41cd0 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createMediaTranscodeProTemplate.php @@ -0,0 +1,61 @@ + $region, + 'scheme' => 'https', // 万象接口必须使用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 创建音视频转码 pro 模板 https://cloud.tencent.com/document/product/460/84732 + $result = $cosClient->createMediaTranscodeProTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'TranscodePro', + 'Name' => 'media-transcode-pro-name', + 'Container' => array( + 'Format' => 'mxf', + ), + 'Video' => array( + 'Codec' => 'xavc', + 'Profile' => 'XAVC-HD_intra_420_10bit_class50', + 'Width' => '1440', + 'Height' => '1080', + 'Interlaced' => 'true', + 'Fps' => '30000/1001', + 'Bitrate' => '', + 'Rotate' => '', + ), + 'TimeInterval' => array( + 'Start' => '', + 'Duration' => '', + ), + 'Audio' => array( + 'Codec' => '', + 'Remove' => '', + ), + 'TransConfig' => array( + 'AdjDarMethod' => '', + 'IsCheckReso' => '', + 'ResoAdjMethod' => '', + 'IsCheckVideoBitrate' => '', + 'VideoBitrateAdjMethod' => '', + 'IsCheckAudioBitrate' => '', + 'AudioBitrateAdjMethod' => '', + 'IsCheckVideoFps' => '', + 'VideoFpsAdjMethod' => '', + 'DeleteMetadata' => '', + 'IsHdr2Sdr' => '', + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createMediaVideoEnhanceJobs.php b/vendor/qcloud/cos-sdk-v5/sample/createMediaVideoEnhanceJobs.php new file mode 100644 index 0000000..2a11735 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createMediaVideoEnhanceJobs.php @@ -0,0 +1,201 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 提交画质增强任务 https://cloud.tencent.com/document/product/460/84775 + // start --------------- 使用模版 ----------------- // + $result = $cosClient->createMediaVideoEnhanceJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'VideoEnhance', + 'Input' => array( + 'Object' => 'test.mp4', + ), + 'Operation' => array( + 'TemplateId' => '', // 画质增强模板 ID + 'Output' => array( + 'Region' => $region, + 'Bucket' => 'examplebucket-125000000', + 'Object' => 'tmp/output.mp4', + ), +// 'UserData' => 'xxx', +// 'JobLevel' => '0', +// 'WatermarkTemplateId' => array( +// 'WatermarkTemplateId-1', +// 'WatermarkTemplateId-2', +// ), +// 'Watermark' => array( +// array( +// 'Type' => '', +// 'Pos' => '', +// 'LocMode' => '', +// 'Dx' => '', +// 'Dy' => '', +// 'StartTime' => '', +// 'EndTime' => '', +// 'Image' => array( +// 'Url' => '', +// 'Mode' => '', +// 'Width' => '', +// 'Height' => '', +// 'Transparency' => '', +// 'Background' => '', +// ), +// 'Text' => array( +// 'FontSize' => '', +// 'FontType' => '', +// 'FontColor' => '', +// 'Transparency' => '', +// 'Text' => '', +// ), +// 'SlideConfig' => array( +// 'SlideMode' => '', +// 'XSlideSpeed' => '', +// 'YSlideSpeed' => '', +// ), +// ), +// ), +// 'DigitalWatermark' => array( +// 'Message' => '', +// 'Type' => '', +// 'Version' => '', +// 'IgnoreError' => '', +// 'State' => '', +// ), + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); + // end --------------- 使用模版 ----------------- // + + // start --------------- 自定义参数 ----------------- // + $result = $cosClient->createMediaVideoEnhanceJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'VideoEnhance', + 'Input' => array( + 'Object' => 'test.mp4', + ), + 'Operation' => array( + // 画质增强参数 + 'VideoEnhance' => array( + 'Transcode' => array( + 'Container' => array( + 'Format' => 'mp4', + ), + 'Video' => array( + 'Codec' => 'H.264', + 'Width' => '1280', + 'Height' => '920', + 'Fps' => '30', + ), + 'Audio' => array( + 'Codec' => 'aac', + 'Samplerate' => '44100', + 'Bitrate' => '128', + 'Channels' => '4', + ), + ), + 'SuperResolution' => array( + 'Resolution' => 'sdtohd', + 'EnableScaleUp' => 'true', + 'Version' => 'Enhance', + ), + 'SDRtoHDR' => array( + 'HdrMode' => 'HDR10', + ), + 'ColorEnhance' => array( + 'Contrast' => '50', + 'Correction' => '100', + 'Saturation' => '100', + ), + 'MsSharpen' => array( + 'SharpenLevel' => '5', + ), + 'FrameEnhance' => array( + 'FrameDoubling' => 'true', + ), + ), + 'Output' => array( + 'Region' => $region, + 'Bucket' => 'examplebucket-125000000', + 'Object' => 'tmp/output.mp4', + ), +// 'UserData' => 'xxx', +// 'JobLevel' => '0', +// 'WatermarkTemplateId' => array( +// 'WatermarkTemplateId-1', +// 'WatermarkTemplateId-2', +// ), +// 'Watermark' => array( +// array( +// 'Type' => '', +// 'Pos' => '', +// 'LocMode' => '', +// 'Dx' => '', +// 'Dy' => '', +// 'StartTime' => '', +// 'EndTime' => '', +// 'Image' => array( +// 'Url' => '', +// 'Mode' => '', +// 'Width' => '', +// 'Height' => '', +// 'Transparency' => '', +// 'Background' => '', +// ), +// 'Text' => array( +// 'FontSize' => '', +// 'FontType' => '', +// 'FontColor' => '', +// 'Transparency' => '', +// 'Text' => '', +// ), +// 'SlideConfig' => array( +// 'SlideMode' => '', +// 'XSlideSpeed' => '', +// 'YSlideSpeed' => '', +// ), +// ), +// ), +// 'DigitalWatermark' => array( +// 'Message' => '', +// 'Type' => '', +// 'Version' => '', +// 'IgnoreError' => '', +// 'State' => '', +// ), + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); + // end --------------- 自定义参数 ----------------- // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createMediaVideoEnhanceTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/createMediaVideoEnhanceTemplate.php new file mode 100644 index 0000000..6c4d37a --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createMediaVideoEnhanceTemplate.php @@ -0,0 +1,65 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // https://cloud.tencent.com/document/product/460/84722 创建画质增强模板 + $result = $cosClient->createMediaVideoEnhanceTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'VideoEnhance', + 'Name' => 'TemplateName', + 'VideoEnhance' => array( + 'Transcode' => array( + 'Container' => array( + 'Format' => 'mp4', + ), + 'Video' => array( + 'Codec' => 'H.264', + 'Width' => '1280', + 'Height' => '920', + 'Fps' => '30', + ), + 'Audio' => array( + 'Codec' => 'aac', + 'Samplerate' => '44100', + 'Bitrate' => '128', + 'Channels' => '4', + ), + ), + 'SuperResolution' => array( + 'Resolution' => 'sdtohd', + 'EnableScaleUp' => 'true', + 'Version' => 'Enhance', + ), + 'SDRtoHDR' => array( + 'HdrMode' => 'HDR10', + ), + 'ColorEnhance' => array( + 'Contrast' => '50', + 'Correction' => '100', + 'Saturation' => '100', + ), + 'MsSharpen' => array( + 'SharpenLevel' => '5', + ), + 'FrameEnhance' => array( + 'FrameDoubling' => 'true', + ), + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createVoiceSoundHoundJobs.php b/vendor/qcloud/cos-sdk-v5/sample/createVoiceSoundHoundJobs.php new file mode 100644 index 0000000..c18f1e0 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createVoiceSoundHoundJobs.php @@ -0,0 +1,41 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 提交听歌识曲任务 https://cloud.tencent.com/document/product/460/84795 + $result = $cosClient->createVoiceSoundHoundJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'SoundHound', + 'Input' => array( + 'Object' => 'test.mp3', + ), + 'Operation' => array( + 'UserData' => 'xxx', // 透传用户信息 + 'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0 + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createVoiceSpeechRecognitionJobs.php b/vendor/qcloud/cos-sdk-v5/sample/createVoiceSpeechRecognitionJobs.php new file mode 100644 index 0000000..7176ae0 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createVoiceSpeechRecognitionJobs.php @@ -0,0 +1,95 @@ + $region, + 'scheme' => 'https', // 万象接口必须使用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 提交一个语音识别任务 https://cloud.tencent.com/document/product/460/84798 + // 1. 使用模版 + $result = $cosClient->createVoiceSpeechRecognitionJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'SpeechRecognition', + 'Input' => array( + 'Object' => 'test.mp3', +// 'Url' => '', + ), + 'Operation' => array( + 'TemplateId' => '', +// 'UserData' => '', +// 'JobLevel' => '', + 'Output' => array( + 'Region' => $region, + 'Bucket' => 'examplebucket-125000000', + 'Object' => 'xxx.txt', + ), + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); + + // 2. 自定义参数 + $result = $cosClient->createVoiceSpeechRecognitionJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'SpeechRecognition', + 'Input' => array( + 'Object' => 'test.mp3', +// 'Url' => '', + ), + 'Operation' => array( +// 'UserData' => '', +// 'JobLevel' => '', + 'SpeechRecognition' => array( + 'EngineModelType' => '16k_zh', + 'ChannelNum' => 1, + 'ResTextFormat' => 1, + 'FilterDirty' => 0, + 'FilterModal' => 1, + 'ConvertNumMode' => 0, + 'SpeakerDiarization' => 1, + 'SpeakerNumber' => 0, + 'FilterPunc' => 0, +// 'OutputFileType' => 'txt', +// 'FlashAsr' => 'true', +// 'Format' => 'mp3', +// 'FirstChannelOnly' => 1, +// 'WordInfo' => 1, +// 'SentenceMaxLength' => 6, + ), + 'Output' => array( + 'Region' => $region, + 'Bucket' => 'examplebucket-125000000', + 'Object' => 'xxx.txt', + ), + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createVoiceSpeechRecognitionTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/createVoiceSpeechRecognitionTemplate.php new file mode 100644 index 0000000..fd13b14 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createVoiceSpeechRecognitionTemplate.php @@ -0,0 +1,44 @@ + $region, + 'scheme' => 'https', // 万象接口必须使用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 创建语音识别模板 https://cloud.tencent.com/document/product/460/84498 + $result = $cosClient->createVoiceSpeechRecognitionTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'SpeechRecognition', + 'Name' => 'voice-speechrecognition-name', + 'SpeechRecognition' => array( + 'EngineModelType' => '16k_zh', + 'ChannelNum' => 1, + 'ResTextFormat' => 1, + 'FilterDirty' => 0, + 'FilterModal' => 1, + 'ConvertNumMode' => 0, + 'SpeakerDiarization' => 1, + 'SpeakerNumber' => 0, + 'FilterPunc' => 0, + 'OutputFileType' => 'txt', +// 'FlashAsr' => 'true', +// 'Format' => 'mp3', +// 'FirstChannelOnly' => 1, +// 'WordInfo' => 1, +// 'SentenceMaxLength' => 6, + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createVoiceTtsJobs.php b/vendor/qcloud/cos-sdk-v5/sample/createVoiceTtsJobs.php new file mode 100644 index 0000000..91be274 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createVoiceTtsJobs.php @@ -0,0 +1,86 @@ + $region, + 'scheme' => 'https', // 万象接口必须使用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 提交一个语音合成任务 https://cloud.tencent.com/document/product/460/84797 + // 1. 使用模版 + $result = $cosClient->createVoiceTtsJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'Tts', // 固定为 Tts + 'Operation' => array( + 'TemplateId' => 't1460606b9752148c4ab182f55163ba7cd', + 'TtsConfig' => array( + 'InputType' => 'Text', + 'Input' => '床前明月光,疑是地上霜', + ), + 'Output' => array( + 'Region' => $region, + 'Bucket' => 'examplebucket-125000000', + 'Object' => 'demo.mp3', + ), +// 'UserData' => 'xxx', +// 'JobLevel' => '0', + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); + + // 2. 自定义参数 + $result = $cosClient->createVoiceTtsJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'Tts', // 固定为 Tts + 'Operation' => array( + 'TtsConfig' => array( + 'InputType' => 'Text', + 'Input' => '床前明月光,疑是地上霜', + ), + 'TtsTpl' => array( + 'Mode' => 'Sync', + 'Codec' => 'pcm', + 'VoiceType' => 'aixiaoxing', + 'Volume' => '2', + 'Speed' => '200', + 'Emotion' => 'arousal', + ), + 'Output' => array( + 'Region' => $region, + 'Bucket' => 'examplebucket-125000000', + 'Object' => 'demo.mp3', + ), +// 'UserData' => 'xxx', +// 'JobLevel' => '0', + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createVoiceTtsTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/createVoiceTtsTemplate.php new file mode 100644 index 0000000..bf2aaca --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createVoiceTtsTemplate.php @@ -0,0 +1,33 @@ + $region, + 'scheme' => 'https', // 万象接口必须使用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 创建语音合成模板 https://cloud.tencent.com/document/product/460/84499 + $result = $cosClient->createVoiceTtsTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'Tts', + 'Name' => 'TemplateName', + 'Mode' => 'Sync', + 'Codec' => 'pcm', + 'VoiceType' => 'aixiaoxing', + 'Volume' => '2', + 'Speed' => '200', + 'Emotion' => 'arousal', + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/createVoiceVocalScoreJobs.php b/vendor/qcloud/cos-sdk-v5/sample/createVoiceVocalScoreJobs.php new file mode 100644 index 0000000..8a3d291 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/createVoiceVocalScoreJobs.php @@ -0,0 +1,44 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 提交音乐评分任务 https://cloud.tencent.com/document/product/460/96095 + $result = $cosClient->createVoiceVocalScoreJobs(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Tag' => 'VocalScore', + 'Input' => array( + 'Object' => 'test.mp3', + ), + 'Operation' => array( + "VocalScore" => array( + 'StandardObject' => 'test.mp3', + ), +// 'UserData' => 'xxx', // 透传用户信息 +// 'JobLevel' => '0', // 任务优先级,级别限制:0 、1 、2。级别越大任务优先级越高,默认为0 + ), +// 'CallBack' => '', +// 'CallBackFormat' => '', +// 'CallBackType' => '', +// 'CallBackMqConfig' => array( +// 'MqRegion' => '', +// 'MqMode' => '', +// 'MqName' => '', +// ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/detectLabelProcess.php b/vendor/qcloud/cos-sdk-v5/sample/detectLabelProcess.php new file mode 100644 index 0000000..5ba29a8 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/detectLabelProcess.php @@ -0,0 +1,40 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +$local_path = "/data/exampleobject"; +try { + // -------------------- 1. 图片标签 原图存储在COS -------------------- // + $result = $cosClient->detectLabelProcess(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'test.jpg', + 'Scenes' => '', + )); + // 请求成功 + print_r($result); + // -------------------- 1. 图片标签 原图存储在COS -------------------- // + + // -------------------- 2. 图片标签 原图来自其他链接 -------------------- // + $result = $cosClient->detectLabelProcess(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // 该值为空即可 + 'DetectUrl' => 'https://www.xxx.com/xxx.jpg', + 'Scenes' => '', + )); + // 请求成功 + print_r($result); + // -------------------- 2. 图片标签 原图来自其他链接 -------------------- // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/detectPetProcess.php b/vendor/qcloud/cos-sdk-v5/sample/detectPetProcess.php new file mode 100644 index 0000000..eb63a97 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/detectPetProcess.php @@ -0,0 +1,38 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +$local_path = "/data/exampleobject"; +try { + // -------------------- 1. 宠物识别 原图存储在COS -------------------- // + $result = $cosClient->detectPetProcess(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'test.jpg', + )); + // 请求成功 + print_r($result); + // -------------------- 1. 宠物识别 原图存储在COS -------------------- // + + // -------------------- 2. 宠物识别 原图来自其他链接 暂不支持 -------------------- // +// $result = $cosClient->detectPetProcess(array( +// 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket +// 'Key' => '', // 该值为空即可 +// 'DetectUrl' => 'https://www.xxx.com/xxx.jpg', +// )); +// // 请求成功 +// print_r($result); + // -------------------- 2. 宠物识别 原图来自其他链接 暂不支持 -------------------- // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/getAiBucketList.php b/vendor/qcloud/cos-sdk-v5/sample/getAiBucketList.php new file mode 100644 index 0000000..55162c6 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/getAiBucketList.php @@ -0,0 +1,30 @@ + $region, + 'scheme' => 'https', // 万象接口必须用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); + +try { + // 查询 AI 内容识别服务状态 https://cloud.tencent.com/document/product/460/79594 + $result = $cosClient->getAiBucketList(array( +// 'Regions' => '', // 可选 地域信息,例如 ap-shanghai、ap-beijing,若查询多个地域以“,”分隔字符串 +// 'BucketNames' => '', // 可选 存储桶名称,以“,”分隔,支持多个存储桶,精确搜索 +// 'BucketName' => '', // 可选 存储桶名称前缀,前缀搜索 +// 'PageNumber' => 1, // 可选 第几页 +// 'PageSize' => 20, // 可选 每页个数 + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/getAiQueueList.php b/vendor/qcloud/cos-sdk-v5/sample/getAiQueueList.php new file mode 100644 index 0000000..362ee99 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/getAiQueueList.php @@ -0,0 +1,28 @@ + $region, + 'scheme' => 'https', // 万象接口必须为https + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 搜索 AI 内容识别队列 https://cloud.tencent.com/document/product/460/79394 + $result = $cosClient->getAiQueueList(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket +// 'QueueIds' => 'xxx', // 队列 ID,以“,”符号分割字符串 +// 'State' => 'Active', // Active 表示队列内的作业会被媒体处理服务调度执行, Paused 表示队列暂停,作业不再会被媒体处理调度执行,队列内的所有作业状态维持在暂停状态,已经执行中的任务不受影响 +// 'PageNumber' => '1', // 第几页 +// 'PageSize' => '10', // 每页个数 + )); + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/getAsrBucketList.php b/vendor/qcloud/cos-sdk-v5/sample/getAsrBucketList.php new file mode 100644 index 0000000..298034d --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/getAsrBucketList.php @@ -0,0 +1,30 @@ + $region, + 'scheme' => 'https', // 万象接口必须用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); + +try { + // 查询智能语音服务 https://cloud.tencent.com/document/product/460/46232 + $result = $cosClient->getAsrBucketList(array( +// 'Regions' => '', // 可选 地域信息,例如 ap-shanghai、ap-beijing,若查询多个地域以“,”分隔字符串 +// 'BucketNames' => '', // 可选 存储桶名称,以“,”分隔,支持多个存储桶,精确搜索 +// 'BucketName' => '', // 可选 存储桶名称前缀,前缀搜索 +// 'PageNumber' => 1, // 可选 第几页 +// 'PageSize' => 20, // 可选 每页个数 + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/getAsrQueueList.php b/vendor/qcloud/cos-sdk-v5/sample/getAsrQueueList.php new file mode 100644 index 0000000..ccc281a --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/getAsrQueueList.php @@ -0,0 +1,28 @@ + $region, + 'scheme' => 'https', // 万象接口必须为https + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 查询智能语音队列 https://cloud.tencent.com/document/product/460/46234 + $result = $cosClient->getAsrQueueList(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket +// 'QueueIds' => 'xxx', // 队列 ID,以“,”符号分割字符串 +// 'State' => 'Active', // Active 表示队列内的作业会被媒体处理服务调度执行, Paused 表示队列暂停,作业不再会被媒体处理调度执行,队列内的所有作业状态维持在暂停状态,已经执行中的任务不受影响 +// 'PageNumber' => '1', // 第几页 +// 'PageSize' => '10', // 每页个数 + )); + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/getImageSlim.php b/vendor/qcloud/cos-sdk-v5/sample/getImageSlim.php new file mode 100644 index 0000000..f14e807 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/getImageSlim.php @@ -0,0 +1,23 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + $result = $cosClient->getImageSlim(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + )); + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/getPicBucketList.php b/vendor/qcloud/cos-sdk-v5/sample/getPicBucketList.php new file mode 100644 index 0000000..1b6cfb7 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/getPicBucketList.php @@ -0,0 +1,30 @@ + $region, + 'scheme' => 'https', // 万象接口必须用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); + +try { + // 查询图片处理服务状态 + $result = $cosClient->getPicBucketList(array( +// 'Regions' => '', // 可选 地域信息,例如 ap-shanghai、ap-beijing,若查询多个地域以“,”分隔字符串 +// 'BucketNames' => '', // 可选 存储桶名称,以“,”分隔,支持多个存储桶,精确搜索 +// 'BucketName' => '', // 可选 存储桶名称前缀,前缀搜索 +// 'PageNumber' => 1, // 可选 第几页 +// 'PageSize' => 20, // 可选 每页个数 + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/getPicQueueList.php b/vendor/qcloud/cos-sdk-v5/sample/getPicQueueList.php new file mode 100644 index 0000000..8d25a1c --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/getPicQueueList.php @@ -0,0 +1,28 @@ + $region, + 'scheme' => 'https', // 万象接口必须为https + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 搜索图片处理队列 https://cloud.tencent.com/document/product/460/79395 + $result = $cosClient->getPicQueueList(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket +// 'QueueIds' => 'xxx', // 队列 ID,以“,”符号分割字符串 +// 'State' => 'Active', // Active 表示队列内的作业会被媒体处理服务调度执行, Paused 表示队列暂停,作业不再会被媒体处理调度执行,队列内的所有作业状态维持在暂停状态,已经执行中的任务不受影响 +// 'PageNumber' => '1', // 第几页 +// 'PageSize' => '10', // 每页个数 + )); + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/goodsMattingProcess.php b/vendor/qcloud/cos-sdk-v5/sample/goodsMattingProcess.php new file mode 100644 index 0000000..e8202a5 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/goodsMattingProcess.php @@ -0,0 +1,67 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // -------------------- 1. 下载时处理-原图存储在COS -------------------- // + $object = 'xxx.jpg'; + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('GoodsMatting'); + + $query = $ciProcessParams->queryString(); + $downloadUrl = $cosClient->getObjectUrl('examplebucket-1250000000', $object); // 获取下载链接 + echo "{$downloadUrl}&{$query}"; // 携带签名的图片地址以“&”连接 + // -------------------- 1. 下载时处理-原图存储在COS -------------------- // + + // -------------------- 2. 下载时处理-原图来自其他链接 -------------------- // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('GoodsMatting'); + $ciProcessParams->addParam('detect-url', 'https://xxx.com/xxx.jpg'); + + $query = $ciProcessParams->queryString(); + $downloadUrl = $cosClient->getObjectUrl('examplebucket-1250000000', ''); // 获取下载链接 + echo "{$downloadUrl}&{$query}"; + // -------------------- 2. 下载时处理-原图来自其他链接 -------------------- // + + // ---------------------------- 3. 上传时处理 ---------------------------- // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('GoodsMatting'); + + $picOperations = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation(); + $picOperations->setIsPicInfo(1); // is_pic_info + $picOperations->addRule($ciProcessParams, "output.png"); // rules + $result = $cosClient->putObject(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'object.jpg', + 'Body' => fopen('/tmp/local.jpg', 'rb'), // 本地文件 + 'PicOperations' => $picOperations->queryString(), + )); + // 请求成功 + print_r($result); + // ---------------------------- 3. 上传时处理 ---------------------------- // + + // --------------------- 4. 云上数据处理 ------------------------------ // + $ciProcessParams = new Qcloud\Cos\ImageParamTemplate\CIProcessTransformation('GoodsMatting'); + + $picOperations = new Qcloud\Cos\ImageParamTemplate\PicOperationsTransformation(); + $picOperations->setIsPicInfo(1); // is_pic_info + $picOperations->addRule($ciProcessParams, 'output.jpg'); // rules + $result = $cosClient->ImageProcess(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'test.jpg', + 'PicOperations' => $picOperations->queryString(), + )); + // 请求成功 + print_r($result); + // --------------------- 4. 云上数据处理 ------------------------------ // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/livenessRecognitionProcess.php b/vendor/qcloud/cos-sdk-v5/sample/livenessRecognitionProcess.php new file mode 100644 index 0000000..9965cdb --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/livenessRecognitionProcess.php @@ -0,0 +1,20 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 活体人脸核身 待补充 +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/openAiService.php b/vendor/qcloud/cos-sdk-v5/sample/openAiService.php new file mode 100644 index 0000000..d015a38 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/openAiService.php @@ -0,0 +1,24 @@ + $region, + 'scheme' => 'https', // 万象接口必须用https + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 开通 AI 内容识别 https://cloud.tencent.com/document/product/460/79593 + $result = $cosClient->openAiService(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + )); + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/openAsrService.php b/vendor/qcloud/cos-sdk-v5/sample/openAsrService.php new file mode 100644 index 0000000..4ba8173 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/openAsrService.php @@ -0,0 +1,24 @@ + $region, + 'scheme' => 'https', // 万象接口必须用https + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 开通智能语音服务 https://cloud.tencent.com/document/product/460/95754 + $result = $cosClient->openAsrService(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + )); + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/openImageSlim.php b/vendor/qcloud/cos-sdk-v5/sample/openImageSlim.php new file mode 100644 index 0000000..c4b990d --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/openImageSlim.php @@ -0,0 +1,30 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials' => array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + $result = $cosClient->openImageSlim(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'SlimMode' => 'API', + 'Suffixs' => array( + 'Suffix' => array( + 'jpg', + 'png', + ), + ), + )); + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/recognizeLogoProcess.php b/vendor/qcloud/cos-sdk-v5/sample/recognizeLogoProcess.php new file mode 100644 index 0000000..aa2c7bb --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/recognizeLogoProcess.php @@ -0,0 +1,38 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +$local_path = "/data/exampleobject"; +try { + // -------------------- 1. Logo 识别 原图存储在COS -------------------- // + $result = $cosClient->recognizeLogoProcess(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => 'test.jpg', + )); + // 请求成功 + print_r($result); + // -------------------- 1. Logo 识别 原图存储在COS -------------------- // + + // -------------------- 2. Logo 识别 原图来自其他链接 -------------------- // + $result = $cosClient->recognizeLogoProcess(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // 该值为空即可 + 'DetectUrl' => 'https://www.xxx.com/xxx.jpg', + )); + // 请求成功 + print_r($result); + // -------------------- 2. Logo 识别 原图来自其他链接 -------------------- // +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/sts_demo.php b/vendor/qcloud/cos-sdk-v5/sample/sts_demo.php new file mode 100644 index 0000000..e9722fe --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/sts_demo.php @@ -0,0 +1,102 @@ + 1700828878 + * [expiration] => 2023-11-24T12:27:58Z + * [credentials] => Array + * ( + * [sessionToken] => token + * [tmpSecretId] => secretId + * [tmpSecretKey] => secretKey + * ) + * + * [requestId] => 2a521211-b212-xxxx-xxxx-c9976a3966bd + * [startTime] => 1700810878 + * ) + */ + +require_once __DIR__ . '/vendor/autoload.php'; + +$bucket = 'examplebucket-1250000000'; +$secretKey = 'SECRETKEY'; +$secretId = 'SECRETID'; +$region = "ap-beijing"; + +$sts = new QCloud\COSSTS\Sts(); +$config = array( + 'url' => 'https://sts.tencentcloudapi.com/', // url和domain保持一致 + 'domain' => 'sts.tencentcloudapi.com', // 域名,非必须,默认为 sts.tencentcloudapi.com + 'proxy' => '', + 'secretId' => $secretId, // 固定密钥,若为明文密钥,请直接以'xxx'形式填入,不要填写到getenv()函数中 + 'secretKey' => $secretKey, // 固定密钥,若为明文密钥,请直接以'xxx'形式填入,不要填写到getenv()函数中 + 'bucket' => $bucket, // 换成你的 bucket + 'region' => $region, // 换成 bucket 所在园区 + 'durationSeconds' => 1800*10, // 密钥有效期 + 'allowPrefix' => array('/*'), // 这里改成允许的路径前缀,可以根据自己网站的用户登录态判断允许上传的具体路径,例子: a.jpg 或者 a/* 或者 * (使用通配符*存在重大安全风险, 请谨慎评估使用) + 'allowCiSource' => false, // 万象资源配置 + 'allowActions' => array ( + 'name/cos:*', + 'name/ci:*', + // 具体action按需设置 + ), +// // 临时密钥生效条件,关于condition的详细设置规则和COS支持的condition类型可以参考 https://cloud.tencent.com/document/product/436/71306 +// "condition" => array( +// "ip_equal" => array( +// "qcs:ip" => array( +// "10.217.182.3/24", +// "111.21.33.72/24", +// ) +// ) +// ) +); + + +try { + // 获取临时密钥,计算签名 + $tempKeys = $sts->getTempKeys($config); + print_r($tempKeys); +} catch (Exception $e) { + echo $e; +} + + +/** + * 第二步:在cos php sdk中使用临时密钥 + * 创建临时密钥生成的Client,以文本同步审核为例 + */ +// 临时密钥 +$tmpSecretId = 'secretId'; // 第一步获取到的 $tempKeys['credentials']['tmpSecretId'] +$tmpSecretKey = 'secretKey'; // 第一步获取到的 $tempKeys['credentials']['tmpSecretKey'] +$token = 'token'; // 第一步获取到的 $tempKeys['credentials']['sessionToken'] +$tokenClient = new Qcloud\Cos\Client( + array( + 'region' => $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $tmpSecretId , + 'secretKey' => $tmpSecretKey, + 'token' => $token, + ) + ) +); + +try { + $content = '敏感词'; + $result = $tokenClient->detectText(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Input' => array( + 'Content' => base64_encode($content), // 文本需base64_encode + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/updateAiQueue.php b/vendor/qcloud/cos-sdk-v5/sample/updateAiQueue.php new file mode 100644 index 0000000..d517371 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/updateAiQueue.php @@ -0,0 +1,38 @@ + $region, + 'scheme' => 'https', // 万象接口必须为https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 更新 AI 内容识别队列 https://cloud.tencent.com/document/product/460/79397 + $result = $cosClient->updateAiQueue(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // queueId + 'Name' => 'queue-ai-process', + 'State' => 'Active', + 'NotifyConfig' => array( + 'State' => 'Off', +// 'Event' => '', +// 'ResultFormat' => '', +// 'Type' => '', +// 'Url' => '', +// 'MqMode' => '', +// 'MqRegion' => '', +// 'MqName' => '', + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/updateAsrQueue.php b/vendor/qcloud/cos-sdk-v5/sample/updateAsrQueue.php new file mode 100644 index 0000000..5127efa --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/updateAsrQueue.php @@ -0,0 +1,38 @@ + $region, + 'scheme' => 'https', // 万象接口必须为https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 更新智能语音队列 https://cloud.tencent.com/document/product/460/46235 + $result = $cosClient->updateAsrQueue(array( + 'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // queueId + 'Name' => 'queue-smart-audio', + 'State' => 'Active', + 'NotifyConfig' => array( + 'State' => 'Off', +// 'Event' => '', +// 'ResultFormat' => '', +// 'Type' => '', +// 'Url' => '', +// 'MqMode' => '', +// 'MqRegion' => '', +// 'MqName' => '', + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/updateMediaNoiseReductionTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/updateMediaNoiseReductionTemplate.php new file mode 100644 index 0000000..cb56b32 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/updateMediaNoiseReductionTemplate.php @@ -0,0 +1,32 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 更新音频降噪模板 https://cloud.tencent.com/document/product/460/94394 + $result = $cosClient->updateMediaNoiseReductionTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // TemplateId + 'Tag' => 'NoiseReduction', + 'Name' => 'NoiseReduction-Template', + 'NoiseReduction' => array( + 'Format' => 'wav', + 'Samplerate' => '16000', + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/updateMediaSmartCoverTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/updateMediaSmartCoverTemplate.php new file mode 100644 index 0000000..7789d28 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/updateMediaSmartCoverTemplate.php @@ -0,0 +1,35 @@ + $region, + 'scheme' => 'https', // 万象接口必须使用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 更新智能封面模板 https://cloud.tencent.com/document/product/460/84755 + $result = $cosClient->updateMediaSmartCoverTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // TemplateId + 'Tag' => 'SmartCover', + 'Name' => 'media-smartcover-name', + 'SmartCover' => array( + 'Format' => 'jpg', + 'Width' => '1280', + 'Height' => '960', + 'Count' => '3', + 'DeleteDuplicates' => 'true', + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/updateMediaTargetRecTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/updateMediaTargetRecTemplate.php new file mode 100644 index 0000000..3460168 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/updateMediaTargetRecTemplate.php @@ -0,0 +1,33 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 更新视频目标检测模板 + $result = $cosClient->updateMediaTargetRecTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // TemplateId + 'Tag' => 'VideoTargetRec', + 'Name' => 'template-name', + 'VideoTargetRec' => array( + 'Body' => 'true', + 'Pet' => 'true', + 'Car' => 'false', + ), // Body、Pet、Car 不能同时为 false + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/updateMediaTranscodeProTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/updateMediaTranscodeProTemplate.php new file mode 100644 index 0000000..1ba0070 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/updateMediaTranscodeProTemplate.php @@ -0,0 +1,62 @@ + $region, + 'scheme' => 'https', // 万象接口必须使用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 更新音视频转码 pro 模板 https://cloud.tencent.com/document/product/460/84753 + $result = $cosClient->updateMediaTranscodeProTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // TemplateId + 'Tag' => 'TranscodePro', + 'Name' => 'media-transcode-pro-name', + 'Container' => array( + 'Format' => 'mxf', + ), + 'Video' => array( + 'Codec' => 'xavc', + 'Profile' => 'XAVC-HD_intra_420_10bit_class50', + 'Width' => '1440', + 'Height' => '1080', + 'Interlaced' => 'true', + 'Fps' => '30000/1001', + 'Bitrate' => '', + 'Rotate' => '', + ), + 'TimeInterval' => array( + 'Start' => '', + 'Duration' => '', + ), + 'Audio' => array( + 'Codec' => '', + 'Remove' => '', + ), + 'TransConfig' => array( + 'AdjDarMethod' => '', + 'IsCheckReso' => '', + 'ResoAdjMethod' => '', + 'IsCheckVideoBitrate' => '', + 'VideoBitrateAdjMethod' => '', + 'IsCheckAudioBitrate' => '', + 'AudioBitrateAdjMethod' => '', + 'IsCheckVideoFps' => '', + 'VideoFpsAdjMethod' => '', + 'DeleteMetadata' => '', + 'IsHdr2Sdr' => '', + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/updateMediaVideoEnhanceTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/updateMediaVideoEnhanceTemplate.php new file mode 100644 index 0000000..0216bc6 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/updateMediaVideoEnhanceTemplate.php @@ -0,0 +1,66 @@ + $region, + 'scheme' => 'https', //协议头部,默认为http + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // https://cloud.tencent.com/document/product/460/84745 更新画质增强模板 + $result = $cosClient->updateMediaVideoEnhanceTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // TemplateId + 'Tag' => 'VideoEnhance', + 'Name' => 'TemplateName', + 'VideoEnhance' => array( + 'Transcode' => array( + 'Container' => array( + 'Format' => 'mp4', + ), + 'Video' => array( + 'Codec' => 'H.264', + 'Width' => '1280', + 'Height' => '920', + 'Fps' => '30', + ), + 'Audio' => array( + 'Codec' => 'aac', + 'Samplerate' => '44100', + 'Bitrate' => '128', + 'Channels' => '4', + ), + ), + 'SuperResolution' => array( + 'Resolution' => 'sdtohd', + 'EnableScaleUp' => 'true', + 'Version' => 'Enhance', + ), + 'SDRtoHDR' => array( + 'HdrMode' => 'HDR10', + ), + 'ColorEnhance' => array( + 'Contrast' => '50', + 'Correction' => '100', + 'Saturation' => '100', + ), + 'MsSharpen' => array( + 'SharpenLevel' => '5', + ), + 'FrameEnhance' => array( + 'FrameDoubling' => 'true', + ), + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/updatePicQueue.php b/vendor/qcloud/cos-sdk-v5/sample/updatePicQueue.php new file mode 100644 index 0000000..cf11634 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/updatePicQueue.php @@ -0,0 +1,38 @@ + $region, + 'scheme' => 'https', // 万象接口必须为https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 更新图片处理队列 https://cloud.tencent.com/document/product/460/79396 + $result = $cosClient->updatePicQueue(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // queueId + 'Name' => 'queue-pic-process', + 'State' => 'Active', + 'NotifyConfig' => array( + 'State' => 'Off', +// 'Event' => '', +// 'ResultFormat' => '', +// 'Type' => '', +// 'Url' => '', +// 'MqMode' => '', +// 'MqRegion' => '', +// 'MqName' => '', + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/updateVoiceSpeechRecognitionTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/updateVoiceSpeechRecognitionTemplate.php new file mode 100644 index 0000000..b037e82 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/updateVoiceSpeechRecognitionTemplate.php @@ -0,0 +1,45 @@ + $region, + 'scheme' => 'https', // 万象接口必须使用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 更新语音识别模板 https://cloud.tencent.com/document/product/460/84759 + $result = $cosClient->updateVoiceSpeechRecognitionTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // TemplateId + 'Tag' => 'SpeechRecognition', + 'Name' => 'voice-speechrecognition-name', + 'SpeechRecognition' => array( + 'EngineModelType' => '16k_zh', + 'ChannelNum' => 1, + 'ResTextFormat' => 1, + 'FilterDirty' => 0, + 'FilterModal' => 1, + 'ConvertNumMode' => 0, + 'SpeakerDiarization' => 1, + 'SpeakerNumber' => 0, + 'FilterPunc' => 0, + 'OutputFileType' => 'txt', +// 'FlashAsr' => 'true', +// 'Format' => 'mp3', +// 'FirstChannelOnly' => 1, +// 'WordInfo' => 1, +// 'SentenceMaxLength' => 6, + ), + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/qcloud/cos-sdk-v5/sample/updateVoiceTtsTemplate.php b/vendor/qcloud/cos-sdk-v5/sample/updateVoiceTtsTemplate.php new file mode 100644 index 0000000..d57ee31 --- /dev/null +++ b/vendor/qcloud/cos-sdk-v5/sample/updateVoiceTtsTemplate.php @@ -0,0 +1,34 @@ + $region, + 'scheme' => 'https', // 万象接口必须使用https + 'credentials'=> array( + 'secretId' => $secretId, + 'secretKey' => $secretKey))); +try { + // 更新语音合成模板 https://cloud.tencent.com/document/product/460/84758 + $result = $cosClient->updateVoiceTtsTemplate(array( + 'Bucket' => 'examplebucket-125000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.cloud.tencent.com/cos5/bucket + 'Key' => '', // TemplateId + 'Tag' => 'Tts', + 'Name' => 'TemplateName', + 'Mode' => 'Sync', + 'Codec' => 'pcm', + 'VoiceType' => 'aixiaoxing', + 'Volume' => '2', + 'Speed' => '200', + 'Emotion' => 'arousal', + )); + // 请求成功 + print_r($result); +} catch (\Exception $e) { + // 请求失败 + echo($e); +} diff --git a/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php b/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php new file mode 100644 index 0000000..512bba0 --- /dev/null +++ b/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php @@ -0,0 +1,119 @@ + 'i̇', + 'µ' => 'μ', + 'ſ' => 's', + 'ͅ' => 'ι', + 'ς' => 'σ', + 'ϐ' => 'β', + 'ϑ' => 'θ', + 'ϕ' => 'φ', + 'ϖ' => 'π', + 'ϰ' => 'κ', + 'ϱ' => 'ρ', + 'ϵ' => 'ε', + 'ẛ' => 'ṡ', + 'ι' => 'ι', + 'ß' => 'ss', + 'ʼn' => 'ʼn', + 'ǰ' => 'ǰ', + 'ΐ' => 'ΐ', + 'ΰ' => 'ΰ', + 'և' => 'եւ', + 'ẖ' => 'ẖ', + 'ẗ' => 'ẗ', + 'ẘ' => 'ẘ', + 'ẙ' => 'ẙ', + 'ẚ' => 'aʾ', + 'ẞ' => 'ss', + 'ὐ' => 'ὐ', + 'ὒ' => 'ὒ', + 'ὔ' => 'ὔ', + 'ὖ' => 'ὖ', + 'ᾀ' => 'ἀι', + 'ᾁ' => 'ἁι', + 'ᾂ' => 'ἂι', + 'ᾃ' => 'ἃι', + 'ᾄ' => 'ἄι', + 'ᾅ' => 'ἅι', + 'ᾆ' => 'ἆι', + 'ᾇ' => 'ἇι', + 'ᾈ' => 'ἀι', + 'ᾉ' => 'ἁι', + 'ᾊ' => 'ἂι', + 'ᾋ' => 'ἃι', + 'ᾌ' => 'ἄι', + 'ᾍ' => 'ἅι', + 'ᾎ' => 'ἆι', + 'ᾏ' => 'ἇι', + 'ᾐ' => 'ἠι', + 'ᾑ' => 'ἡι', + 'ᾒ' => 'ἢι', + 'ᾓ' => 'ἣι', + 'ᾔ' => 'ἤι', + 'ᾕ' => 'ἥι', + 'ᾖ' => 'ἦι', + 'ᾗ' => 'ἧι', + 'ᾘ' => 'ἠι', + 'ᾙ' => 'ἡι', + 'ᾚ' => 'ἢι', + 'ᾛ' => 'ἣι', + 'ᾜ' => 'ἤι', + 'ᾝ' => 'ἥι', + 'ᾞ' => 'ἦι', + 'ᾟ' => 'ἧι', + 'ᾠ' => 'ὠι', + 'ᾡ' => 'ὡι', + 'ᾢ' => 'ὢι', + 'ᾣ' => 'ὣι', + 'ᾤ' => 'ὤι', + 'ᾥ' => 'ὥι', + 'ᾦ' => 'ὦι', + 'ᾧ' => 'ὧι', + 'ᾨ' => 'ὠι', + 'ᾩ' => 'ὡι', + 'ᾪ' => 'ὢι', + 'ᾫ' => 'ὣι', + 'ᾬ' => 'ὤι', + 'ᾭ' => 'ὥι', + 'ᾮ' => 'ὦι', + 'ᾯ' => 'ὧι', + 'ᾲ' => 'ὰι', + 'ᾳ' => 'αι', + 'ᾴ' => 'άι', + 'ᾶ' => 'ᾶ', + 'ᾷ' => 'ᾶι', + 'ᾼ' => 'αι', + 'ῂ' => 'ὴι', + 'ῃ' => 'ηι', + 'ῄ' => 'ήι', + 'ῆ' => 'ῆ', + 'ῇ' => 'ῆι', + 'ῌ' => 'ηι', + 'ῒ' => 'ῒ', + 'ῖ' => 'ῖ', + 'ῗ' => 'ῗ', + 'ῢ' => 'ῢ', + 'ῤ' => 'ῤ', + 'ῦ' => 'ῦ', + 'ῧ' => 'ῧ', + 'ῲ' => 'ὼι', + 'ῳ' => 'ωι', + 'ῴ' => 'ώι', + 'ῶ' => 'ῶ', + 'ῷ' => 'ῶι', + 'ῼ' => 'ωι', + 'ff' => 'ff', + 'fi' => 'fi', + 'fl' => 'fl', + 'ffi' => 'ffi', + 'ffl' => 'ffl', + 'ſt' => 'st', + 'st' => 'st', + 'ﬓ' => 'մն', + 'ﬔ' => 'մե', + 'ﬕ' => 'մի', + 'ﬖ' => 'վն', + 'ﬗ' => 'մխ', +]; diff --git a/vendor/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php b/vendor/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php new file mode 100644 index 0000000..eb5952e --- /dev/null +++ b/vendor/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (\PHP_VERSION_ID >= 70400 && extension_loaded('curl')) { + /** + * @property string $data + */ + class CURLStringFile extends CURLFile + { + private $data; + + public function __construct(string $data, string $postname, string $mime = 'application/octet-stream') + { + $this->data = $data; + parent::__construct('data://application/octet-stream;base64,'.base64_encode($data), $mime, $postname); + } + + public function __set(string $name, $value): void + { + if ('data' !== $name) { + $this->$name = $value; + + return; + } + + if (is_object($value) ? !method_exists($value, '__toString') : !is_scalar($value)) { + throw new \TypeError('Cannot assign '.gettype($value).' to property CURLStringFile::$data of type string'); + } + + $this->name = 'data://application/octet-stream;base64,'.base64_encode($value); + } + + public function __isset(string $name): bool + { + return isset($this->$name); + } + + public function &__get(string $name) + { + return $this->$name; + } + } +} diff --git a/vendor/symfony/psr-http-message-bridge/ArgumentValueResolver/ValueResolverInterface.php b/vendor/symfony/psr-http-message-bridge/ArgumentValueResolver/ValueResolverInterface.php new file mode 100644 index 0000000..83a321a --- /dev/null +++ b/vendor/symfony/psr-http-message-bridge/ArgumentValueResolver/ValueResolverInterface.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PsrHttpMessage\ArgumentValueResolver; + +use Symfony\Component\HttpKernel\Controller\ValueResolverInterface as BaseValueResolverInterface; + +if (interface_exists(BaseValueResolverInterface::class)) { + /** @internal */ + interface ValueResolverInterface extends BaseValueResolverInterface + { + } +} else { + /** @internal */ + interface ValueResolverInterface + { + } +} diff --git a/vendor/topthink/framework/src/think/console/bin/README.md b/vendor/topthink/framework/src/think/console/bin/README.md new file mode 100644 index 0000000..9acc52f --- /dev/null +++ b/vendor/topthink/framework/src/think/console/bin/README.md @@ -0,0 +1 @@ +console 工具使用 hiddeninput.exe 在 windows 上隐藏密码输入,该二进制文件由第三方提供,相关源码和其他细节可以在 [Hidden Input](https://github.com/Seldaek/hidden-input) 找到。 diff --git a/vendor/topthink/framework/src/think/console/bin/hiddeninput.exe b/vendor/topthink/framework/src/think/console/bin/hiddeninput.exe new file mode 100644 index 0000000000000000000000000000000000000000..c8cf65e8d819e6e525121cf6b21f1c2429746038 GIT binary patch literal 9216 zcmeHNe{@sVeZR8hV88~S)=Hp|Mpn({rC^@)BwNOI{ERJXCYlx+k1K6PLHo z_e!z_fhOzeA3JTX&-Z@s{rFOgjEwBlqjr!)9f zjyHz`A+ni`!0Taby{Uj5Y>jQq(k5A+X})PLWAi|{IZbtc8n^^trM{GI=P_15U6d?l zJJ3PW8XjfHpR}6`k{&5@JcEeH_SqQoQbU62o2YS30W)p_t&Fjy*RXQCZt$gCf|ao| zx&3R}m6|-Lfi@pua=$26n(UlnWo$>K67*|+#(qL_An=?l0M02AhOSJDv3;~?1ORfw z76EdK#MpSHqACHLcnJLIYlCSiX4eS@Pr8rN)Xwz0dk7O*y^0_C(Yks2Kvg! z-d-fJ)F9@k?>)m(XqDKIe2OKfhCQde9fpO0ko24yn*4xzX7q+ze`Z*=aJgwV?D?73 zaJ8UkSk|NN>@-|mB*f`EIK7$ElgAB<7p&p`^Vuq$58#;?B^*Bz7&d$B#+AYUC z(^m|`7{lqx&b^5$;i`j|S!+u|lcaQplp_&Nb)!>r>vGh3wb!tW zLq6%bkSt8jO|(vWH>LiPV(Xkp%BiGhl1q!PXXNKVKE!>Y5cHc2%cJOJA{-&ZsSn`T z#8~TA#(HWH4m>uCd+kCMTFgMI*s*n3!iCOwEI`{vGcVhzDu!Lw%-Ea^JATtrF`q3`+#KvvYJ0vM~A}D#LOD zlw`4ncB0U*Jji=--Wz#>I&5?hy;MgYW2u91d8ob=7MWfY`u;7Xe-J{Qsb0=0p|SM2 zG|=~mERIj4?gi)Ew|{LIN#oAsh20k_khIYjJBBN6rrIJ=eQO=nE;rTnPSiaQS$1$# z+|JRh0!IbQIa*f1(TZ}QM;|WO0+jTy(e)ggN4>zqp2E>C>hGPLHjHBh--2%@{EZNE zbUk{<3MABX&20QwK{MxK8`1Vk>^%dO5i@VTfu>NG3$K4NC=hSPsj9UYy`rNO}sBnB9QdKdIk7G+2_amnWstdTYVg z7HgLJGC~XLZG`63GwH8PdO_+G(k6~?J8Wj5mQos#21kC4W#2)guQXI)!z^{@F)U)5 z*re+r(2dib3D4P~%Z6TL=$PIkpmm<_#isu%t=%DcIwNkJhMeJ|bpahHO%8h|y~Ccf zUg#xVk+dyu>Q1O7JZ~8KS>tqi0qK**X*y6yHM71`bT=kFZ=@E%oe2!Km1^2sa>v+onZ%x_>aOJF+N0{i~z|<(IzgT*{0PpQq}E zQpU35@bm;qI?t_znGI&5&4sZV>+%m}w$(4hSDvLk)l<{5XyMlnCl7C%AjM3XnWvVz z{NoFsX)JB)SoqABZxUa*Yq+^^(cbq4mL%^lO12c${z{pf+)|kTTI~nQywyYF6}6|8 zlsN9&{-vwTrTyu<5^90_AsIU-ID#ZG@6d%poU44<**%xVe?`uxf}_Mr$SLHLS|K_N zQnw>(Lr2U=%$-<2D~RSzbG)2W2u^KMDnFFE?GmmbQ)V)fty957F`4OvQ_25E68ITr z5?`suu`|v?r!y=gFOGj$%9IJ zuTP=&2GcnoZZ0qSe6YL-*-lg>Q#>?Ew`a=GDc4vI#<1sNdKn?n7iSj0Orl$-#FMFi zykr>X-Xvi>sVr;92+8*H!r|3L$#o~hXa0z>AmF=z z?|@FF;*S|S0yqsw0j>Z(3mX-HD!|{N-vYc9paC8Ld=|6?00!6(_%lERupO`&um*4k z0b~W>e*uhTe4;V;mq>(ox$9FB`wLt!*DKj~!aOh|fL&#Pg*b??tm%5~_6M#02wqeC zS~wO>TWGnSp^r<0&8f2V6W->w=C+p~daC5e5wNQM*(* z66^}b0(!q3)zq$mu&VnbR#nr3;h5DS*o7{y66=!#;Dy4$pd1ZH<6WEOi0oJ8SxRL* z*v-9@Z^2w%^S(w5dO{_9Duby%2RT~;ppxaE$l()x6&}>7Wcg=u_&>f`Vs8OJGTy{X z2HpG=ThJz<{%|4Qq-~ad0qcrc87n88DHpM(nypwXIkZn<{zIT$ul&BQ?{ApCAZtyr zs2YpNt@x(G*faTU*HCKnAk(G=Tl~>r1QK8LY~J8mFFGoN5iIkYSwlm4Lsj#g4dsE5 zU-4;*Kdh-zv!rT4N$O}Q&n)?v0-9Y)lRFz58^P-KtKonzrfQ1p@0V_10^0||cGRn9 zRG<-#_TEV2nn4{BOh{YVBR4e!V!D?0K%BAlQN!D%M#k1bHypiIHT)5tlj>p0Pp_;+ z!cqC-JIs@JRhB+#teGs$Cib_=(yjRo4OJg^YPg%58aJVsC(LQ?W6%pn!-#aMZwoPcopo^Rn6BE z3=c5&W5~pP(C(-2r;PnH-S0{F`runM0ERCf3rESX$+S(MKOXmKJL9zXF}9-lf^xUs z+bb)+P%L&gV@<4q{6w^xEJ>Y>TQFUeoz0o-yq)jUqww=?wjUO8Y{a5G;DJ0Jr!LL+ zWhgsLuzi&eDrGDn$2DJwpFfH-?SGWbr>qRb?v{P`_%)So)CQgzO^HQ%;y#tJ=knH4 z95jX;^bF#BiuTH^%-j}{9VrZD=R%Q%wselH^p>5 z7d>gWB-st&3Fj%Mt*|tR5iK3J=`xhs&G)I7E>`FO@o7L z@S$B!pYMuzz5DN@X!O4DPm5n@raPJn-Q#o*m*e^5lk$g?0esg%$;>g5QW-|;c=H2GM}bo2tW^D924wmOkrUbWxcQ# z#v6bP%Tdfe~jtCRzAL;-OahZ=#yvUixu2-9fD2j$*|YY`F?0wF-{a# ztr<&kZjZ+81}6ZESqtgW)8kP#s@VLTSUR{}6?U^R*x7RE3Rl&n=VnFFqg9Uqz1n@N9N|=9<4} zuJfy^+}|D9X&vm3MAdqmu0&UMd^=K>b1hLAm_E!$rZC2b;;T~Dl zI`Eo_yRY76uM})|6wk9->of(=9&4jLv5#p@OzS~Yl>@pG)^>6`R+KtL{<4ly4o9WiM!%p_pfROU354)e8PIeE z1_s?#;OX6waNvvb&UQRN(WLbR+}&b#jo&WY-LlwCX}Q*$jGuKYuOGoIoyR(>e}}ix z+t}Q^cEcC8Y{@h}>HmJ^gD!l@gzwHmiBKl26x_lZVZG2UY!`w;RJd122;US&geQdW z3Qq}R!gIo5;ka;0I4c-Jq5X6A6?VzK&c4y!ZXdAUYu{r}*!SBXw?Aor+J4-A(*COb zb^CwV-?3k`zi-cX*c`VzL`RLI(b4MgIrGN z%ojf`E*6)Gg1A9!7q^N##2zsss^V9~-Qt7d!{UDNZ^XY9pA^3@9ui*?e=7c5d`nD; z?}~R(p>y1Kw!>|X4ycYEAkcZa*n-R%y! zqi)Up756UpqwfE7=hfigw$k~G@25gaxF9UGTkV>C(7x1Rbx4jb#|}rxq0vQ!n-c#f J0sQ~1{4brj`U(I5 literal 0 HcmV?d00001 diff --git a/vendor/topthink/framework/src/think/route/ResourceRegister.php b/vendor/topthink/framework/src/think/route/ResourceRegister.php new file mode 100644 index 0000000..6a34787 --- /dev/null +++ b/vendor/topthink/framework/src/think/route/ResourceRegister.php @@ -0,0 +1,72 @@ + +// +---------------------------------------------------------------------- +declare (strict_types = 1); + +namespace think\route; + +/** + * 资源路由注册类 + */ +class ResourceRegister +{ + /** + * 资源路由 + * @var Resource + */ + protected $resource; + + /** + * 是否注册过 + * @var bool + */ + protected $registered = false; + + /** + * 架构函数 + * @access public + * @param Resource $resource 资源路由 + */ + public function __construct(Resource $resource) + { + $this->resource = $resource; + } + + /** + * 注册资源路由 + * @access protected + * @return void + */ + protected function register() + { + $this->registered = true; + + $this->resource->parseGroupRule($this->resource->getRule()); + } + + /** + * 动态方法 + * @access public + * @param string $method 方法名 + * @param array $args 调用参数 + * @return mixed + */ + public function __call($method, $args) + { + return call_user_func_array([$this->resource, $method], $args); + } + + public function __destruct() + { + if (!$this->registered) { + $this->register(); + } + } +} diff --git a/vendor/w7corp/easywechat/docs/.npmrc b/vendor/w7corp/easywechat/docs/.npmrc new file mode 100644 index 0000000..3e775ef --- /dev/null +++ b/vendor/w7corp/easywechat/docs/.npmrc @@ -0,0 +1 @@ +auto-install-peers=true diff --git a/vendor/w7corp/easywechat/docs/src/4.x/client.md b/vendor/w7corp/easywechat/docs/src/4.x/client.md new file mode 100644 index 0000000..78dc586 --- /dev/null +++ b/vendor/w7corp/easywechat/docs/src/4.x/client.md @@ -0,0 +1,44 @@ +# API 调用 + +该方法将 API 交由开发者自行调用,微信有部分新的接口4.x并未全部兼容支持,可以使用该方案去自行封装接口: + +例如URL Link接口 + +```php + +$response = $app->httpPostJson('wxa/generate_urllink',[ + 'path' => 'pages/index/index', + 'is_expire' => true, + 'expire_type' => 1, + 'expire_interval' => 1 +]); +``` + +## 语法说明 + +```php +httpGet(string $uri, array $query = []) +httpPostJson(string $uri, array $data = [], array $query = []) +``` + + + +### GET + +```php +$response = $app->httpGet('/cgi-bin/user/list', [ + 'next_openid' => 'OPENID1', +]); +``` + +### POST + +```php +$response = $app->httpPostJson('/cgi-bin/user/info/updateremark', [ + "openid" => "oDF3iY9ffA-hqb2vVvbr7qxf6A0Q", + "remark" => "pangzi" +]); +``` + + + diff --git a/vendor/w7corp/easywechat/docs/src/5.x/mini-program/shipping.md b/vendor/w7corp/easywechat/docs/src/5.x/mini-program/shipping.md new file mode 100644 index 0000000..679ec4f --- /dev/null +++ b/vendor/w7corp/easywechat/docs/src/5.x/mini-program/shipping.md @@ -0,0 +1,117 @@ +# 小程序发货信息管理 + +> 微信文档 https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html + + +## 发货信息录入接口 + +```php +$data = [ + 'order_key' => [ + 'order_number_type' => 1, + 'mchid' => '', + 'out_trade_no' => '' + ], + 'logistics_type' => 4, + 'delivery_mode' => 1, + 'shipping_list' => [ + 'tracking_no' => '323244567777', + 'express_company' => 'DHL', + 'item_desc' => '微信红包抱枕*1个', + 'contact' => [ + 'consignor_contact' => '189****1234', + 'receiver_contact' => '189****1234' + ], + ], + 'upload_time' => '2022-12-15T13:29:35.120+08:00', + 'payer' => [ + 'openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o' + ] +]; + +$app->shipping->uploadShippingInfo($data); +``` + +## 发货信息合单录入接口 + +```php + $data = [ + 'order_key' => [ + 'order_number_type' => 1, + 'mchid' => '', + 'out_trade_no' => '' + ], + 'sub_orders' => [ + 'order_key' => [ + 'order_number_type' => 1, + 'transaction_id' => '', + 'mchid' => '', + 'out_trade_no' => '' + ], + 'logistics_type' => 4, + 'delivery_mode' => 1, + 'shipping_list' => [ + 'tracking_no' => '323244567777', + 'express_company' => 'DHL', + 'item_desc' => '微信红包抱枕*1个', + 'contact' => [ + 'consignor_contact' => '189****1234', + 'receiver_contact' => '189****1234' + ], + ], + ], + 'upload_time' => '2022-12-15T13:29:35.120+08:00', + 'payer' => [ + 'openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o' + ] +]; + +$app->shipping->uploadCombineShippingInfo($data); +``` + +## 查询订单发货状态 + +```php +$data = $app->shipping->getOrder([ + 'transaction_id' => 'xxx' +]); +``` + +## 查询订单列表 + +```php +$data = $app->shipping->getOrderList(); +``` + +## 确认收货提醒接口 + +```php +$data = [ + 'transaction_id' => '42000020212023112332159214xx', + 'received_time' => '' +]; + +$app->shipping->notifyConfirmReceive($data); +``` + +## 消息跳转路径设置接口 + +```php +$data = [ + 'path' => 'pages/goods/order_detail?id=xxxx', +]; + +$app->shipping->setMsgJumpPath($data); +``` + +## 查询小程序是否已开通发货信息管理服务 + +```php +$app->shipping->isTradeManaged(); +``` + +## 查询小程序是否已完成交易结算管理确认 + +```php +$app->shipping->isTradeCompleted(); +``` diff --git a/vendor/w7corp/easywechat/docs/src/6.x/pay/media.md b/vendor/w7corp/easywechat/docs/src/6.x/pay/media.md new file mode 100644 index 0000000..991f5a5 --- /dev/null +++ b/vendor/w7corp/easywechat/docs/src/6.x/pay/media.md @@ -0,0 +1,32 @@ +## 文件上传 6.10.0+ + +由于微信 v3 对文件类上传使用特殊的签名机制,参见:[微信支付 - 图片上传API](https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter2_1_1.shtml)。 + +因此,我们提供了一个媒体上传方法,方便开发者使用。 + +```php +$path = '/path/to/your/files/demo.jpg'; + +$api->uploadMedia('/v3/marketing/favor/media/image-upload', $path); +``` + +## 自定义 meta 信息 + +部分接口使用的签名 meta 不一致,所以可以自行传入: + +```php +$url = '/v3/...'; +$path = '/path/to/your/files/demo.jpg'; +$meta = [ + 'bank_type' => 'CFT', + 'filename' => 'demo.jpg', + 'sha256' => 'xxxxxxxxxxx', +]; + +$api->uploadMedia($url, $path, $meta); +``` + +## 关于 sha256 + +- 文件,用 `hash_file('sha256', $path)` 计算 +- 字符串,用 `hash('sha256', $string)` 计算 diff --git a/vendor/w7corp/easywechat/src/Kernel/Contracts/JsApiTicket.php b/vendor/w7corp/easywechat/src/Kernel/Contracts/JsApiTicket.php new file mode 100644 index 0000000..27616d2 --- /dev/null +++ b/vendor/w7corp/easywechat/src/Kernel/Contracts/JsApiTicket.php @@ -0,0 +1,15 @@ + + */ + public function configSignature(string $url, string $nonce, int $timestamp): array; +} diff --git a/vendor/w7corp/easywechat/src/Kernel/Contracts/RefreshableJsApiTicket.php b/vendor/w7corp/easywechat/src/Kernel/Contracts/RefreshableJsApiTicket.php new file mode 100644 index 0000000..c0ec8ed --- /dev/null +++ b/vendor/w7corp/easywechat/src/Kernel/Contracts/RefreshableJsApiTicket.php @@ -0,0 +1,8 @@ +client = $client; + $this->defaultOptionsByRegexp = $defaultOptionsByRegexp; + } + + public function request(string $method, string $url, array $options = []): ResponseInterface + { + foreach ($this->defaultOptionsByRegexp as $regexp => $defaultOptions) { + if (preg_match($regexp, $url)) { + $options = self::mergeDefaultOptions($options, $defaultOptions, true); + break; + } + } + + return $this->client->request($method, $url, $options); + } + + public function stream(ResponseInterface|iterable $responses, ?float $timeout = null): ResponseStreamInterface + { + return $this->client->stream($responses, $timeout); + } + + /** + * @return void + */ + public function reset() + { + if ($this->client instanceof ResetInterface) { + $this->client->reset(); + } + } + + public function setLogger(LoggerInterface $logger): void + { + if ($this->client instanceof LoggerAwareInterface) { + $this->client->setLogger($logger); + } + } +} diff --git a/vendor/w7corp/easywechat/src/OpenWork/JsApiTicket.php b/vendor/w7corp/easywechat/src/OpenWork/JsApiTicket.php new file mode 100644 index 0000000..492a12c --- /dev/null +++ b/vendor/w7corp/easywechat/src/OpenWork/JsApiTicket.php @@ -0,0 +1,165 @@ +httpClient = $httpClient ?? HttpClient::create(['base_uri' => 'https://qyapi.weixin.qq.com/']); + $this->cache = $cache ?? new Psr16Cache(new FilesystemAdapter(namespace: 'easywechat', defaultLifetime: 1500)); + } + + /** + * @return array + * + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws InvalidArgumentException + * @throws HttpException + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + */ + public function createConfigSignature(string $nonce, int $timestamp, string $url, array $jsApiList = [], bool $debug = false, bool $beta = true): array + { + return [ + 'appId' => $this->corpId, + 'nonceStr' => $nonce, + 'timestamp' => $timestamp, + 'url' => $url, + 'signature' => $this->getTicketSignature($this->getTicket(), $nonce, $timestamp, $url), + 'jsApiList' => $jsApiList, + 'debug' => $debug, + 'beta' => $beta, + ]; + } + + public function getTicketSignature(string $ticket, string $nonce, int $timestamp, string $url): string + { + return sha1(sprintf('jsapi_ticket=%s&noncestr=%s×tamp=%s&url=%s', $ticket, $nonce, $timestamp, $url)); + } + + /** + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws InvalidArgumentException + * @throws TransportExceptionInterface + * @throws HttpException + * @throws ServerExceptionInterface + */ + public function getTicket(): string + { + $key = $this->getKey(); + $ticket = $this->cache->get($key); + + if ((bool) $ticket && is_string($ticket)) { + return $ticket; + } + + $response = $this->httpClient->request('GET', '/cgi-bin/get_jsapi_ticket')->toArray(false); + + if (empty($response['ticket'])) { + throw new HttpException('Failed to get jssdk ticket: '.json_encode($response, JSON_UNESCAPED_UNICODE)); + } + + $this->cache->set($key, $response['ticket'], intval($response['expires_in'])); + + return $response['ticket']; + } + + public function setKey(string $key): static + { + $this->key = $key; + + return $this; + } + + public function getKey(): string + { + return $this->key ?? $this->key = sprintf('open_work.jsapi_ticket.%s', $this->corpId); + } + + /** + * @throws ClientExceptionInterface + * @throws DecodingExceptionInterface + * @throws HttpException + * @throws InvalidArgumentException + * @throws RedirectionExceptionInterface + * @throws ServerExceptionInterface + * @throws TransportExceptionInterface + */ + public function createAgentConfigSignature(int $agentId, string $nonce, int $timestamp, string $url, array $jsApiList = []): array + { + return [ + 'corpid' => $this->corpId, + 'agentid' => $agentId, + 'nonceStr' => $nonce, + 'timestamp' => $timestamp, + 'signature' => $this->getTicketSignature($this->getAgentTicket($agentId), $nonce, $timestamp, $url), + 'jsApiList' => $jsApiList, + ]; + } + + /** + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws InvalidArgumentException + * @throws ClientExceptionInterface + * @throws HttpException + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + */ + public function getAgentTicket(int $agentId): string + { + $key = $this->getAgentKey($agentId); + $ticket = $this->cache->get($key); + + if ((bool) $ticket && is_string($ticket)) { + return $ticket; + } + + $response = $this->httpClient->request('GET', '/cgi-bin/ticket/get', ['query' => ['type' => 'agent_config']])->toArray(false); + + if (empty($response['ticket'])) { + throw new HttpException('Failed to get jssdk agentTicket: '.json_encode($response, JSON_UNESCAPED_UNICODE)); + } + + $this->cache->set($key, $response['ticket'], intval($response['expires_in'])); + + return $response['ticket']; + } + + public function getAgentKey(int $agentId): string + { + return sprintf('%s.%s', $this->getKey(), $agentId); + } +} diff --git a/vendor/w7corp/easywechat/src/Pay/Contracts/Validator.php b/vendor/w7corp/easywechat/src/Pay/Contracts/Validator.php new file mode 100644 index 0000000..e06eeea --- /dev/null +++ b/vendor/w7corp/easywechat/src/Pay/Contracts/Validator.php @@ -0,0 +1,15 @@ +hasHeader($header)) { + throw new InvalidSignatureException("Missing Header: {$header}"); + } + } + + [$timestamp] = $message->getHeader(self::HEADER_TIMESTAMP); + [$nonce] = $message->getHeader(self::HEADER_NONCE); + [$serial] = $message->getHeader(self::HEADER_SERIAL); + [$signature] = $message->getHeader(self::HEADER_SIGNATURE); + + $body = (string) $message->getBody(); + + $message = "{$timestamp}\n{$nonce}\n{$body}\n"; + + if (\time() - \intval($timestamp) > self::MAX_ALLOWED_CLOCK_OFFSET) { + throw new InvalidSignatureException('Clock Offset Exceeded'); + } + + $publicKey = $this->merchant->getPlatformCert($serial); + + if (! $publicKey) { + throw new InvalidConfigException( + "No platform certs found for serial: {$serial}, + please download from wechat pay and set it in merchant config with key `certs`." + ); + } + + if (\openssl_verify( + $message, + base64_decode($signature), + strval($publicKey), + OPENSSL_ALGO_SHA256 + ) === false) { + throw new InvalidSignatureException('Invalid Signature'); + } + } +}