API | 操作名 | 操作描述 |
检索对象内容 | 从指定对象(CSV 格式或者 JSON 格式)中检索内容 |
cos:GetObject
的授权。try{// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";string key = "exampleobject"; //对象键SelectObjectRequest 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());}
本页内容是否解决了您的问题?