API | 操作名 | 操作描述 |
预请求跨域配置 | 用预请求来确认是否可以发送真正的跨域请求 |
// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.tencentcloud.com/cos5/bucketString bucket = "examplebucket-1250000000";String cosPath = "exampleobject"; //对象位于存储桶中的位置标识符,即对象键String origin = "https://cloud.tencent.com";String accessMethod = "PUT";OptionObjectRequest optionObjectRequest = new OptionObjectRequest(bucket,cosPath, origin,accessMethod);cosXmlService.optionObjectAsync(optionObjectRequest,new CosXmlResultListener() {@Overridepublic void onSuccess(CosXmlRequest cosXmlRequest, CosXmlResult result) {OptionObjectResult optionObjectResult = (OptionObjectResult) result;}// 如果您使用 kotlin 语言来调用,请注意回调方法中的异常是可空的,否则不会回调 onFail 方法,即:// clientException 的类型为 CosXmlClientException?,serviceException 的类型为 CosXmlServiceException?@Overridepublic void onFail(CosXmlRequest cosXmlRequest,@Nullable CosXmlClientException clientException,@Nullable CosXmlServiceException serviceException) {if (clientException != null) {clientException.printStackTrace();} else {serviceException.printStackTrace();}}});
本页内容是否解决了您的问题?