List of usage examples for io.netty.handler.codec.http.multipart MemoryFileUpload setContent
@Override public void setContent(ByteBuf buffer) throws IOException
From source file:reactor.ipc.netty.http.client.HttpClientFormEncoder.java
License:Open Source License
@Override public HttpClientRequest.Form file(String name, String filename, InputStream stream, String contentType) { Objects.requireNonNull(name, "name"); Objects.requireNonNull(stream, "stream"); try {/*from ww w . j a va2s . c o m*/ String scontentType = contentType; if (contentType == null) { scontentType = DEFAULT_BINARY_CONTENT_TYPE; } MemoryFileUpload fileUpload = new MemoryFileUpload(name, filename, scontentType, DEFAULT_TRANSFER_ENCODING, charset, -1); fileUpload.setMaxSize(-1); fileUpload.setContent(stream); addBodyHttpData(fileUpload); } catch (ErrorDataEncoderException e) { throw Exceptions.propagate(e); } catch (IOException e) { throw Exceptions.propagate(new ErrorDataEncoderException(e)); } return this; }
From source file:reactor.ipc.netty.http.client.HttpClientFormEncoder.java
License:Open Source License
@Override public HttpClientRequest.Form textFile(String name, InputStream stream, String contentType) { Objects.requireNonNull(name, "name"); Objects.requireNonNull(stream, "stream"); try {/*from w w w. java 2 s.c om*/ String scontentType = contentType; if (contentType == null) { scontentType = DEFAULT_TEXT_CONTENT_TYPE; } MemoryFileUpload fileUpload = new MemoryFileUpload(name, "", scontentType, null, charset, -1); fileUpload.setMaxSize(-1); fileUpload.setContent(stream); addBodyHttpData(fileUpload); } catch (ErrorDataEncoderException e) { throw Exceptions.propagate(e); } catch (IOException e) { throw Exceptions.propagate(new ErrorDataEncoderException(e)); } return this; }