use of org.jclouds.io.payloads.InputStreamPayload in project camel by apache.
the class JcloudsPayloadConverter method toPayload.
@Converter
public static Payload toPayload(final InputStream is, Exchange exchange) throws IOException {
InputStreamPayload payload = new InputStreamPayload(is);
// only set the contentlength if possible
if (is.markSupported()) {
long contentLength = ByteStreams.length(new InputSupplier<InputStream>() {
@Override
public InputStream getInput() throws IOException {
return is;
}
});
is.reset();
payload.getContentMetadata().setContentLength(contentLength);
}
return payload;
}
use of org.jclouds.io.payloads.InputStreamPayload in project camel by apache.
the class JcloudsPayloadConverter method toPayload.
@Converter
public static Payload toPayload(final StreamSourceCache cache, Exchange exchange) throws IOException {
long contentLength = ByteStreams.length(new InputSupplier<InputStream>() {
@Override
public InputStream getInput() throws IOException {
return cache.getInputStream();
}
});
cache.reset();
InputStreamPayload payload = new InputStreamPayload(cache.getInputStream());
payload.getContentMetadata().setContentLength(contentLength);
setContentMetadata(payload, exchange);
return payload;
}
Aggregations