String region = "ap-beijing";
String commonHeaderKey = "commonexamplekey";
String commonHeaderValue = "commonexamplevalue";
String requestHeaderKey = "requestexamplekey";
String requestHeaderValue = "requestexamplevalue";
CosXmlServiceConfig cosXmlServiceConfig = new CosXmlServiceConfig.Builder()
.isHttps(true)
.setRegion(region)
.setDebuggable(false)
.addHeader(commonHeaderKey, commonHeaderValue)
.builder();
CosXmlService cosXmlService = new CosXmlService(context, cosXmlServiceConfig,
credentialProvider);
HeadObjectRequest headObjectRequest = new HeadObjectRequest(bucket, cosPath);
try {
headObjectRequest.setRequestHeaders(requestHeaderKey, requestHeaderValue, false);
} catch (CosXmlClientException e) {
e.printStackTrace();
}
cosXmlService.headObjectAsync(headObjectRequest, new CosXmlResultListener() {
@Override
public void onSuccess(CosXmlRequest request, CosXmlResult result) {
HeadObjectResult headObjectResult = (HeadObjectResult) result;
}
@Override
public void onFail(CosXmlRequest request, CosXmlClientException clientException,
CosXmlServiceException serviceException) {
if (clientException != null) {
clientException.printStackTrace();
} else {
serviceException.printStackTrace();
}
}
});
Apakah halaman ini membantu?