对象存储 OSS只获取文件元信息
详细解答可以参考官方帮助文档通过headObject方法可以只获文件元信息而不获取文件的实体。代码如下:
// 创建同步获取文件元信息请求HeadObjectRequest head = new HeadObjectRequest('', '');OSSAsyncTask task = oss.asyncHeadObject(head, new OSSCompletedCallbackHeadObjectRequest, HeadObjectResult>() { @Override public void onSuccess(HeadObjectRequest request, HeadObjectResult result) { Log.d('headObject', 'object Size: ' + result.getMetadata().getContentLength()); Log.d('headObject', 'object Content Type: ' + result.getMetadata().getContentType()); } @Override public void onFailure(HeadObjectRequest request, ClientException clientExcepion, ServiceException serviceException) { // 请求异常 if (clientExcepion != null) { // 本地异常如网络异常等 clientExcepion.printStackTrace(); } if (serviceException != null) { // 服务异常 Log.e('ErrorCode', serviceException.getErrorCode()); Log.e('RequestId', serviceException.getRequestId()); Log.e('HostId', serviceException.getHostId()); Log.e('RawMessage', serviceException.getRawMessage()); } }});// task.waitUntilFinished();
赞0
踩1