spring - RxNetty download large file -
i'm trying create controller download large file using rxnetty
i write stupid like
@requestmapping(method = requestmethod.get, path = "largefile") public deferredresult<responseentity<byte[]>> largefile() throws ioexception { observable<responseentity<byte[]>> observable = rxnetty.createhttpget(url) .flatmap(abstracthttpcontentholder::getcontent) .map(data -> { byte[] bytes = new byte[data.readablebytes()]; data.readbytes(bytes); return new responseentity<>(bytes, httpstatus.ok); }); deferredresult<responseentity<byte[]>> deferredresult = new deferredresult<>(); observable.subscribe(deferredresult::setresult, deferredresult::seterrorresult); return deferredresult; }
nevertheless have following error:
caused by: io.netty.handler.codec.toolongframeexception: http content length exceeded 1048576 bytes.
the default client in rxnetty 0.4.x aggregates http payload has limit on maximum content length. exception see because of limit. can alter default client using pipelineconfigurator shown in example:
after payload chunked multiple buffers.
alternatively, if know max size, can use appropriate payload aggregator in configurator.
Comments
Post a Comment