class WritableResource extends BaseResource {

    @POST
    @Path("stream")
    @Consumes(MediaType.APPLICATION_OCTET_STREAM)
    public Response stream(@Context final ServletContext servletContext,
                           @Context HttpHeaders headers,
                           InputStream inputStream) throws Exception {

        RequestContext context = parseRequest(headers);
        Bridge bridge = bridgeFactory.getWriteBridge(context);
        String path = context.getDataSource();

        // Open the output file
        bridge.beginIteration();
        long totalWritten = 0;
        Exception ex = null;

        // dataStream will close automatically in the end of the try.
        // inputStream is closed by dataStream.close().
        try (DataInputStream dataStream = new DataInputStream(inputStream)) {
            while (bridge.setNext(dataStream)) {
                ++totalWritten;
            }
        } catch (ClientAbortException cae) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Remote connection closed by GPDB", cae);
            } else {
                LOG.error("Remote connection closed by GPDB (Enable debug for stacktrace)");
            }
        } catch (Exception e) {
            LOG.error("Exception: totalWritten so far " + totalWritten + " to " + path, e);
            ex = e;
            throw ex;
        } finally {
            try {
                bridge.endIteration();
            } catch (Exception e) {
                throw (ex == null) ? e : ex;
            }
        }

        String censuredPath = Utilities.maskNonPrintables(path);
        String returnMsg = "wrote " + totalWritten + " bulks to " + censuredPath;
        LOG.debug(returnMsg);

        return Response.ok(returnMsg).build();
    }

    public  WritableResource();
      WritableResource(RequestParser<HttpHeaders> parser, BridgeFactory bridgeFactory);

}