Search in sources :

Example 6 with RemoteBinaryFilters

use of org.apache.jackrabbit.oak.remote.RemoteBinaryFilters in project jackrabbit-oak by apache.

the class GetBinaryHandler method handleFile.

/**
     * RFC7233
     * <p/>
     * This handler sends a 200 OK http status, the Content-Length header and
     * the entire file/binary content. This is used when the request Range
     * header is missing or it contains a malformed value.
     */
private void handleFile(HttpServletResponse response, RemoteSession session, RemoteBinaryId binaryId) throws IOException {
    InputStream in = session.readBinary(binaryId, new RemoteBinaryFilters());
    long length = session.readBinaryLength(binaryId);
    response.setStatus(HttpServletResponse.SC_OK);
    response.setContentType("application/octet-stream");
    response.setContentLength((int) length);
    OutputStream out = response.getOutputStream();
    ByteStreams.copy(in, out);
    out.close();
}
Also used : InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) RemoteBinaryFilters(org.apache.jackrabbit.oak.remote.RemoteBinaryFilters)

Aggregations

RemoteBinaryFilters (org.apache.jackrabbit.oak.remote.RemoteBinaryFilters)6 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 Matcher (java.util.regex.Matcher)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 StringTokenizer (java.util.StringTokenizer)1 Blob (org.apache.jackrabbit.oak.api.Blob)1 RemoteBinaryId (org.apache.jackrabbit.oak.remote.RemoteBinaryId)1 RemoteSession (org.apache.jackrabbit.oak.remote.RemoteSession)1 Test (org.junit.Test)1