API | Operation | Description |
Extracting object content | Extracts the content of a specified object (in CSV or JSON format) |
cos:GetObject
.try{// Bucket name in the format of bucketname-APPID. You can get APPID by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";string key = "exampleobject"; // Object keySelectObjectRequest request = new SelectObjectRequest(bucket, key);ObjectSelectionFormat.JSONFormat jSONFormat = new ObjectSelectionFormat.JSONFormat();jSONFormat.Type = "DOCUMENT";jSONFormat.RecordDelimiter = "\\n";string outputFile = "select_local_file.json";request.SetExpression("Select * from COSObject").SetInputFormat(new ObjectSelectionFormat(null, jSONFormat)).SetOutputFormat(new ObjectSelectionFormat(null, jSONFormat)).SetCosProgressCallback(delegate (long progress, long total) {Console.WriteLine("OnProgress : " + progress + "," + total);}).OutputToFile(outputFile);SelectObjectResult selectObjectResult = cosXml.SelectObject(request);Console.WriteLine(selectObjectResult.stat);}catch (COSXML.CosException.CosClientException clientEx){Console.WriteLine("CosClientException: " + clientEx.StackTrace);Console.WriteLine("CosClientException: " + clientEx.Message);}catch (COSXML.CosException.CosServerException serverEx){Console.WriteLine("CosServerException: " + serverEx.GetInfo());}
Was this page helpful?