Search in sources :

Example 1 with MemoryFileUpload

use of io.netty.handler.codec.http.multipart.MemoryFileUpload in project reactor-netty by reactor.

the class HttpClientFormEncoder method textFile.

@Override
public HttpClientRequest.Form textFile(String name, InputStream stream, String contentType) {
    Objects.requireNonNull(name, "name");
    Objects.requireNonNull(stream, "stream");
    try {
        String scontentType = contentType;
        if (contentType == null) {
            scontentType = DEFAULT_TEXT_CONTENT_TYPE;
        }
        MemoryFileUpload fileUpload = new MemoryFileUpload(name, "", scontentType, null, newCharset, -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;
}
Also used : MemoryFileUpload(io.netty.handler.codec.http.multipart.MemoryFileUpload) IOException(java.io.IOException)

Example 2 with MemoryFileUpload

use of io.netty.handler.codec.http.multipart.MemoryFileUpload in project reactor-netty by reactor.

the class HttpClientFormEncoder method file.

@Override
public HttpClientRequest.Form file(String name, String filename, InputStream stream, String contentType) {
    Objects.requireNonNull(name, "name");
    Objects.requireNonNull(stream, "stream");
    try {
        String scontentType = contentType;
        if (contentType == null) {
            scontentType = DEFAULT_BINARY_CONTENT_TYPE;
        }
        MemoryFileUpload fileUpload = new MemoryFileUpload(name, filename, scontentType, DEFAULT_TRANSFER_ENCODING, newCharset, -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;
}
Also used : MemoryFileUpload(io.netty.handler.codec.http.multipart.MemoryFileUpload) IOException(java.io.IOException)

Example 3 with MemoryFileUpload

use of io.netty.handler.codec.http.multipart.MemoryFileUpload in project jocean-http by isdom.

the class HttpPostRequestEncoderTestCase method testMemoryFileUploadEquals.

@Test
public final void testMemoryFileUploadEquals() {
    final MemoryFileUpload f1 = new MemoryFileUpload("m1", "m1", "application/json", null, null, 100);
    assertEquals(f1, f1);
}
Also used : MemoryFileUpload(io.netty.handler.codec.http.multipart.MemoryFileUpload) Test(org.junit.Test)

Example 4 with MemoryFileUpload

use of io.netty.handler.codec.http.multipart.MemoryFileUpload in project reactor-netty by reactor.

the class HttpClientFormEncoder method file.

@Override
public HttpClientForm file(String name, String filename, InputStream stream, @Nullable String contentType) {
    Objects.requireNonNull(name, "name");
    Objects.requireNonNull(stream, "stream");
    try {
        String scontentType = contentType;
        if (contentType == null) {
            scontentType = DEFAULT_BINARY_CONTENT_TYPE;
        }
        MemoryFileUpload fileUpload = new MemoryFileUpload(name, filename, scontentType, DEFAULT_TRANSFER_ENCODING, newCharset, -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;
}
Also used : MemoryFileUpload(io.netty.handler.codec.http.multipart.MemoryFileUpload) IOException(java.io.IOException)

Example 5 with MemoryFileUpload

use of io.netty.handler.codec.http.multipart.MemoryFileUpload in project reactor-netty by reactor.

the class HttpClientFormEncoder method textFile.

@Override
public HttpClientForm textFile(String name, InputStream stream, @Nullable String contentType) {
    Objects.requireNonNull(name, "name");
    Objects.requireNonNull(stream, "stream");
    try {
        String scontentType = contentType;
        if (contentType == null) {
            scontentType = DEFAULT_TEXT_CONTENT_TYPE;
        }
        MemoryFileUpload fileUpload = new MemoryFileUpload(name, "", scontentType, null, newCharset, -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;
}
Also used : MemoryFileUpload(io.netty.handler.codec.http.multipart.MemoryFileUpload) IOException(java.io.IOException)

Aggregations

MemoryFileUpload (io.netty.handler.codec.http.multipart.MemoryFileUpload)12 DefaultHttpDataFactory (io.netty.handler.codec.http.multipart.DefaultHttpDataFactory)5 HttpDataFactory (io.netty.handler.codec.http.multipart.HttpDataFactory)5 HttpPostRequestEncoder (io.netty.handler.codec.http.multipart.HttpPostRequestEncoder)5 IOException (java.io.IOException)5 FileUpload (io.netty.handler.codec.http.multipart.FileUpload)4 Test (org.junit.Test)2 DefaultHttpRequest (io.netty.handler.codec.http.DefaultHttpRequest)1 HttpRequest (io.netty.handler.codec.http.HttpRequest)1 DiskFileUpload (io.netty.handler.codec.http.multipart.DiskFileUpload)1 InterfaceHttpData (io.netty.handler.codec.http.multipart.InterfaceHttpData)1