本文整理了Java中software.amazon.awssdk.utils.IoUtils.copy()
方法的一些代码示例,展示了IoUtils.copy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IoUtils.copy()
方法的具体详情如下:
包路径:software.amazon.awssdk.utils.IoUtils
类名称:IoUtils
方法名:copy
[英]Copies all bytes from the given input stream to the given output stream. Caller is responsible for closing the streams.
[中]将所有字节从给定的输入流复制到给定的输出流。调用方负责关闭流。
代码示例来源:origin: software.amazon.awssdk/sdk-core
/**
* Creates a response transformer that writes all response content to the given {@link OutputStream}. Note that
* the {@link OutputStream} is not closed or flushed after writing.
*
* @param outputStream Output stream to write data to.
* @param <ResponseT> Type of unmarshalled response POJO.
* @return ResponseTransformer instance.
*/
static <ResponseT> ResponseTransformer<ResponseT, ResponseT> toOutputStream(OutputStream outputStream) {
return (resp, in) -> {
InterruptMonitor.checkInterrupted();
IoUtils.copy(in, outputStream);
return resp;
};
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public Optional<RequestBody> modifyHttpContent(Context.ModifyHttpRequest context,
ExecutionAttributes executionAttributes) {
if (!BLACKLIST_METHODS.contains(context.request().getClass()) && context.requestBody().isPresent()
&& !context.httpRequest().firstMatchingHeader(CONTENT_MD5).isPresent()) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
IoUtils.copy(context.requestBody().get().contentStreamProvider().newStream(), baos);
executionAttributes.putAttribute(CONTENT_MD5_ATTRIBUTE, Md5Utils.md5AsBase64(baos.toByteArray()));
return context.requestBody();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
return context.requestBody();
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public HttpExecuteResponse call() throws IOException {
connection.connect();
request.contentStreamProvider().ifPresent(provider ->
invokeSafely(() -> IoUtils.copy(provider.newStream(), connection.getOutputStream())));
int responseCode = connection.getResponseCode();
boolean isErrorResponse = HttpStatusFamily.of(responseCode).isOneOf(CLIENT_ERROR, SERVER_ERROR);
InputStream content = !isErrorResponse ? connection.getInputStream() : connection.getErrorStream();
AbortableInputStream responseBody = content != null ?
AbortableInputStream.create(content) : null;
return HttpExecuteResponse.builder()
.response(SdkHttpResponse.builder()
.statusCode(responseCode)
.statusText(connection.getResponseMessage())
// TODO: Don't ignore abort?
.headers(extractHeaders(connection))
.build())
.responseBody(responseBody)
.build();
}
内容来源于网络,如有侵权,请联系作者删除!