use of com.aliyun.oss.event.ProgressListener in project aliyun-oss-java-sdk by aliyun.
the class OSSUdfOperation method getUdfApplicationLog.
public UdfApplicationLog getUdfApplicationLog(GetUdfApplicationLogRequest getUdfApplicationLogRequest) throws OSSException, ClientException {
assertParameterNotNull(getUdfApplicationLogRequest, "resizeUdfApplicationRequest");
String udfName = getUdfApplicationLogRequest.getName();
assertParameterNotNull(udfName, "udfName");
ensureBucketNameValid(udfName);
Map<String, String> params = new HashMap<String, String>();
populateGetUdfApplicationLogParameters(params, getUdfApplicationLogRequest);
RequestMessage request = new OSSRequestMessageBuilder(getInnerClient()).setEndpoint(getEndpoint()).setMethod(HttpMethod.GET).setParameters(params).setOriginalRequest(getUdfApplicationLogRequest).build();
ProgressListener listener = getUdfApplicationLogRequest.getProgressListener();
UdfApplicationLog udfApplicationLog = null;
try {
publishProgress(listener, ProgressEventType.TRANSFER_STARTED_EVENT);
udfApplicationLog = doOperation(request, new GetUdfApplicationLogResponseParser(udfName), null, null, true);
InputStream instream = udfApplicationLog.getLogContent();
ProgressInputStream progressInputStream = new ProgressInputStream(instream, listener) {
@Override
protected void onEOF() {
publishProgress(getListener(), ProgressEventType.TRANSFER_COMPLETED_EVENT);
}
};
CRC64 crc = new CRC64();
CheckedInputStream checkedInputstream = new CheckedInputStream(progressInputStream, crc);
udfApplicationLog.setLogContent(checkedInputstream);
} catch (RuntimeException e) {
publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT);
throw e;
}
return udfApplicationLog;
}
Aggregations