JobResource.java 文件源码

java
阅读 34 收藏 0 点赞 0 评论 0

项目:jobson 作者:
private Response generateBinaryDataResponse(JobId jobId, Optional<BinaryData> maybeBinaryData) {
    if (maybeBinaryData.isPresent()) {
        final BinaryData binaryData = maybeBinaryData.get();

        final StreamingOutput body = outputStream -> {
            IOUtils.copyLarge(binaryData.getData(), outputStream);
            binaryData.getData().close();
        };

        final Response.ResponseBuilder b =
                Response.ok(body, binaryData.getMimeType())
                        .header("Content-Length", binaryData.getSizeOf());

        if (binaryData.getSizeOf() > Constants.MAX_JOB_OUTPUT_SIZE_IN_BYTES_BEFORE_DISABLING_COMPRESSION)
            b.header("Content-Encoding", "identity");

        return b.build();
    } else {
        return Response.status(404).build();
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号