cos:GetObject. For more authorization information, see CAM-supported business APIs.Feature Name | Description | Example code |
Search object content. | Retrieve content from specified objects (in CSV, JSON, or Parquet format) using Structured Query Language (SQL). |
String bucket = "examplebucket-1250000000";// Objects must be files in JSON or csv format.String cosPath = "exampleobject";final String expression = "Select * from COSObject";SelectObjectContentRequest selectObjectContentRequest = new SelectObjectContentRequest(bucket, cosPath, expression, true,new InputSerialization(CompressionType.NONE, new JSONInput(JSONType.DOCUMENT)),new OutputSerialization(new JSONOutput(",")));// Set the query result callback, which may be called multiple times.selectObjectContentRequest.setSelectObjectContentProgressListener(new SelectObjectContentListener() {@Overridepublic void onProcess(SelectObjectContentEvent event) {}});cosXmlService.selectObjectContentAsync(selectObjectContentRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest request, CosXmlResult result) {SelectObjectContentResult selectObjectContentResult =(SelectObjectContentResult) result;}// If you call the API using kotlin, note that the exception in the callback method must be nullable. Otherwise, the onFail method will not be called, as follows:// The type of clientException is CosXmlClientException?, and the type of serviceException is CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários