12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- require dirname(__FILE__, 2) . '/vendor/autoload.php';
- $secretId = "SECRETID";
- $secretKey = "SECRETKEY";
- $region = "ap-beijing";
- $cosClient = new Qcloud\Cos\Client(array(
- 'region' => $region,
- 'scheme' => 'https',
- 'credentials'=> array(
- 'secretId' => $secretId,
- 'secretKey' => $secretKey
- )
- ));
- try {
- $result = $cosClient->selectObjectContent(array(
- 'Bucket' => 'examplebucket-125000000',
- 'Key' => 'exampleobject',
- 'Expression' => 'Select * from COSObject s',
- 'ExpressionType' => 'SQL',
- 'InputSerialization' => array(
- 'CompressionType' => 'None',
- 'CSV' => array(
- 'FileHeaderInfo' => 'NONE',
- 'RecordDelimiter' => '\n',
- 'FieldDelimiter' => ',',
- 'QuoteEscapeCharacter' => '"',
- 'Comments' => '#',
- 'AllowQuotedRecordDelimiter' => 'FALSE'
- )
- ),
- 'OutputSerialization' => array(
- 'CSV' => array(
- 'QuoteField' => 'ASNEEDED',
- 'RecordDelimiter' => '\n',
- 'FieldDelimiter' => ',',
- 'QuoteCharacter' => '"',
- 'QuoteEscapeCharacter' => '"'
- )
- ),
- 'RequestProgress' => array(
- 'Enabled' => 'FALSE'
- )
- ));
-
- foreach ($result['Data'] as $data) {
-
- print_r($data);
- }
- } catch (\Exception $e) {
-
- echo($e);
- }
- try {
- $result = $cosClient->selectObjectContent(array(
- 'Bucket' => 'examplebucket-125000000',
- 'Key' => 'exampleobject',
- 'Expression' => 'Select * from COSObject s',
- 'ExpressionType' => 'SQL',
- 'InputSerialization' => array(
- 'CompressionType' => 'None',
- 'JSON' => array(
- 'Type' => 'DOCUMENT'
- )
- ),
- 'OutputSerialization' => array(
- 'JSON' => array(
- 'RecordDelimiter' => '\n',
- )
- ),
- 'RequestProgress' => array(
- 'Enabled' => 'FALSE'
- )
- ));
-
- foreach ($result['Data'] as $data) {
-
- print_r($data);
- }
- } catch (\Exception $e) {
-
- echo($e);
- }
|