com.cloudconvert.processor.response.DefaultResponseProcessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cloudconvert-java Show documentation
Show all versions of cloudconvert-java Show documentation
CloudConvert is an online file converter API - more than 200 different audio, video, document, ebook, archive, image, spreadsheet and presentation formats supported.
package com.cloudconvert.processor.response;
import com.cloudconvert.dto.result.Result;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.base.Charsets;
import com.google.common.io.ByteSource;
import org.apache.http.Header;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.stream.Collectors;
public class DefaultResponseProcessor implements ResponseProcessor {
@Override
public Result process(
final int status, final Header[] headers, final InputStream inputStream, final TypeReference typeReference
) throws IOException {
final ByteSource byteSource = new ByteSource() {
@Override
public InputStream openStream() throws IOException {
return inputStream;
}
};
return Result.builder().status(status).headers(Arrays.stream(headers).collect(Collectors.toMap(Header::getName, Header::getValue)))
.message(byteSource.asCharSource(Charsets.UTF_8).read()).build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy