class DataSourceEntityProvider implements EntityProvider<DataSource> {

    @Override
    public void writeTo(DataSource dataSource,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream) throws IOException {
        if (httpHeaders.getFirst(CONTENT_TYPE) == null && !isNullOrEmpty(dataSource.getContentType())) {
            httpHeaders.putSingle(CONTENT_TYPE, dataSource.getContentType());
        }
        try (InputStream in = dataSource.getInputStream()) {
            ByteStreams.copy(in, entityStream);
        }
    }

}