Java Code Examples for retrofit2.http.Part

The following are top voted examples for showing how to use retrofit2.http.Part. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void bodyInNonBodyRequest() {
  class Example {
    @Multipart //
    @PUT("/") //
    Call<ResponseBody> method(@Part("one") String o1, @Body String o2) {
      return null;
    }
  }
  try {
    buildRequest(Example.class);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@Body parameters cannot be used with form or multi-part encoding. (parameter #2)\n    for method Example.method");
  }
}
 
Example 2
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void multipartRequiresName() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part RequestBody part) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@Part annotation must supply a name or use MultipartBody.Part parameter type. (parameter #1)\n"
            + "    for method Example.method");
  }
}
 
Example 3
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void multipartOkHttpPartForbidsName() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("name") MultipartBody.Part part) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@Part parameters using the MultipartBody.Part must not include a part name in the annotation. (parameter #1)\n"
            + "    for method Example.method");
  }
}
 
Example 4
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void multipartArrayOkHttpPart() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("ping") MultipartBody.Part[] part) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@Part parameters using the MultipartBody.Part must not include a part name in the annotation. (parameter #1)\n"
            + "    for method Example.method");
  }
}
 
Example 5
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void multipartPartMapRejectsOkHttpPartValues() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<String, MultipartBody.Part> parts) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@PartMap values cannot be MultipartBody.Part. Use @Part List<Part> or a different value type instead. (parameter #1)\n"
            + "    for method Example.method");
  }
}
 
Example 6
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void bodyInNonBodyRequest() {
  class Example {
    @Multipart //
    @PUT("/") //
    Call<ResponseBody> method(@Part("one") String o1, @Body String o2) {
      return null;
    }
  }
  try {
    buildRequest(Example.class);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@Body parameters cannot be used with form or multi-part encoding. (parameter #2)\n    for method Example.method");
  }
}
 
Example 7
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void multipartRequiresName() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part RequestBody part) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@Part annotation must supply a name or use MultipartBody.Part parameter type. (parameter #1)\n"
            + "    for method Example.method");
  }
}
 
Example 8
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void multipartIterableRequiresName() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part List<RequestBody> part) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@Part annotation must supply a name or use MultipartBody.Part parameter type. (parameter #1)\n"
            + "    for method Example.method");
  }
}
 
Example 9
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void multipartOkHttpPartForbidsName() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("name") MultipartBody.Part part) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@Part parameters using the MultipartBody.Part must not include a part name in the annotation. (parameter #1)\n"
            + "    for method Example.method");
  }
}
 
Example 10
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void multipartIterableOkHttpPart() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("ping") List<MultipartBody.Part> part) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@Part parameters using the MultipartBody.Part must not include a part name in the annotation. (parameter #1)\n"
            + "    for method Example.method");
  }
}
 
Example 11
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void multipartArrayOkHttpPart() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("ping") MultipartBody.Part[] part) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@Part parameters using the MultipartBody.Part must not include a part name in the annotation. (parameter #1)\n"
            + "    for method Example.method");
  }
}
 
Example 12
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void multipartPartMapRejectsOkHttpPartValues() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Map<String, MultipartBody.Part> parts) {
      return null;
    }
  }

  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@PartMap values cannot be MultipartBody.Part. Use @Part List<Part> or a different value type instead. (parameter #1)\n"
            + "    for method Example.method");
  }
}
 
Example 13
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void multipartNullRemovesPart() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("ping") String ping, @Part("fizz") String fizz) {
      return null;
    }
  }
  Request request = buildRequest(Example.class, "pong", null);
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"")
      .contains("\r\npong\r\n--");
}
 
Example 14
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 6 votes vote down vote up
@Test public void multipartPartsShouldBeInOrder() throws IOException {
  class Example {
    @Multipart
    @POST("/foo")
    Call<ResponseBody> get(@Part("first") String data, @Part("second") String dataTwo, @Part("third") String dataThree) {
      return null;
    }
  }
  Request request = buildRequest(Example.class, "firstParam", "secondParam", "thirdParam");
  MultipartBody body = (MultipartBody) request.body();

  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String readBody = buffer.readUtf8();

  assertThat(readBody.indexOf("firstParam")).isLessThan(readBody.indexOf("secondParam"));
  assertThat(readBody.indexOf("secondParam")).isLessThan(readBody.indexOf("thirdParam"));
}
 
Example 15
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void implicitMultipartForbidden() {
  class Example {
    @POST("/") //
    Call<ResponseBody> method(@Part("a") int a) {
      return null;
    }
  }
  try {
    buildRequest(Example.class);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@Part parameters can only be used with multipart encoding. (parameter #1)\n    for method Example.method");
  }
}
 
Example 16
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void simpleMultipart() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("ping") String ping, @Part("kit") RequestBody kit) {
      return null;
    }
  }

  Request request = buildRequest(Example.class, "pong", RequestBody.create(
      MediaType.parse("text/plain"), "kat"));
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"\r\n")
      .contains("\r\npong\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"kit\"")
      .contains("\r\nkat\r\n--");
}
 
Example 17
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void multipartArray() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("ping") String[] ping) {
      return null;
    }
  }

  Request request =
      buildRequest(Example.class, new Object[] { new String[] { "pong1", "pong2" } });
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"\r\n")
      .contains("\r\npong1\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"")
      .contains("\r\npong2\r\n--");
}
 
Example 18
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void multipartOkHttpIterablePart() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part List<MultipartBody.Part> part) {
      return null;
    }
  }

  MultipartBody.Part part1 = MultipartBody.Part.createFormData("foo", "bar");
  MultipartBody.Part part2 = MultipartBody.Part.createFormData("kit", "kat");
  Request request = buildRequest(Example.class, Arrays.asList(part1, part2));
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"foo\"\r\n")
      .contains("\r\nbar\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"kit\"\r\n")
      .contains("\r\nkat\r\n--");
}
 
Example 19
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void multipartOkHttpArrayPart() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part MultipartBody.Part[] part) {
      return null;
    }
  }

  MultipartBody.Part part1 = MultipartBody.Part.createFormData("foo", "bar");
  MultipartBody.Part part2 = MultipartBody.Part.createFormData("kit", "kat");
  Request request =
      buildRequest(Example.class, new Object[] { new MultipartBody.Part[] { part1, part2 } });
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"foo\"\r\n")
      .contains("\r\nbar\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"kit\"\r\n")
      .contains("\r\nkat\r\n--");
}
 
Example 20
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void multipartIterable() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("ping") List<String> ping) {
      return null;
    }
  }

  Request request = buildRequest(Example.class, Arrays.asList("pong1", "pong2"));
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"\r\n")
      .contains("\r\npong1\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"")
      .contains("\r\npong2\r\n--");
}
 
Example 21
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void multipartWithEncoding() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part(value = "ping", encoding = "8-bit") String ping,
        @Part(value = "kit", encoding = "7-bit") RequestBody kit) {
      return null;
    }
  }

  Request request = buildRequest(Example.class, "pong", RequestBody.create(
      MediaType.parse("text/plain"), "kat"));
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"\r\n")
      .contains("Content-Transfer-Encoding: 8-bit")
      .contains("\r\npong\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"kit\"")
      .contains("Content-Transfer-Encoding: 7-bit")
      .contains("\r\nkat\r\n--");
}
 
Example 22
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void multipartPartOptional() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("ping") RequestBody ping) {
      return null;
    }
  }
  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalStateException e) {
    assertThat(e.getMessage()).isEqualTo("Multipart body must have at least one part.");
  }
}
 
Example 23
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void simpleMultipart() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("ping") String ping, @Part("kit") RequestBody kit) {
      return null;
    }
  }

  Request request = buildRequest(Example.class, "pong", RequestBody.create(
      MediaType.parse("text/plain"), "kat"));
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"\r\n")
      .contains("\r\npong\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"kit\"")
      .contains("\r\nkat\r\n--");
}
 
Example 24
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void multipartArray() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("ping") String[] ping) {
      return null;
    }
  }

  Request request =
      buildRequest(Example.class, new Object[] { new String[] { "pong1", "pong2" } });
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"\r\n")
      .contains("\r\npong1\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"")
      .contains("\r\npong2\r\n--");
}
 
Example 25
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void multipartOkHttpIterablePart() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part List<MultipartBody.Part> part) {
      return null;
    }
  }

  MultipartBody.Part part1 = MultipartBody.Part.createFormData("foo", "bar");
  MultipartBody.Part part2 = MultipartBody.Part.createFormData("kit", "kat");
  Request request = buildRequest(Example.class, Arrays.asList(part1, part2));
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"foo\"\r\n")
      .contains("\r\nbar\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"kit\"\r\n")
      .contains("\r\nkat\r\n--");
}
 
Example 26
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void multipartOkHttpArrayPart() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part MultipartBody.Part[] part) {
      return null;
    }
  }

  MultipartBody.Part part1 = MultipartBody.Part.createFormData("foo", "bar");
  MultipartBody.Part part2 = MultipartBody.Part.createFormData("kit", "kat");
  Request request =
      buildRequest(Example.class, new Object[] { new MultipartBody.Part[] { part1, part2 } });
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"foo\"\r\n")
      .contains("\r\nbar\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"kit\"\r\n")
      .contains("\r\nkat\r\n--");
}
 
Example 27
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void multipartIterable() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("ping") List<String> ping) {
      return null;
    }
  }

  Request request = buildRequest(Example.class, Arrays.asList("pong1", "pong2"));
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"\r\n")
      .contains("\r\npong1\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"")
      .contains("\r\npong2\r\n--");
}
 
Example 28
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void multipartWithEncoding() throws IOException {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part(value = "ping", encoding = "8-bit") String ping,
        @Part(value = "kit", encoding = "7-bit") RequestBody kit) {
      return null;
    }
  }

  Request request = buildRequest(Example.class, "pong", RequestBody.create(
      MediaType.parse("text/plain"), "kat"));
  assertThat(request.method()).isEqualTo("POST");
  assertThat(request.headers().size()).isZero();
  assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");

  RequestBody body = request.body();
  Buffer buffer = new Buffer();
  body.writeTo(buffer);
  String bodyString = buffer.readUtf8();

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"ping\"\r\n")
      .contains("Content-Transfer-Encoding: 8-bit")
      .contains("\r\npong\r\n--");

  assertThat(bodyString)
      .contains("Content-Disposition: form-data;")
      .contains("name=\"kit\"")
      .contains("Content-Transfer-Encoding: 7-bit")
      .contains("\r\nkat\r\n--");
}
 
Example 29
Project: GitHub   File: RequestBuilderTest.java   Source Code and License 5 votes vote down vote up
@Test public void multipartPartOptional() {
  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Part("ping") RequestBody ping) {
      return null;
    }
  }
  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalStateException e) {
    assertThat(e.getMessage()).isEqualTo("Multipart body must have at least one part.");
  }
}
 
Example 30
Project: EvolvingNetLib   File: CCNetApiService.java   Source Code and License 5 votes vote down vote up
/**
 * 上传文件
 * @param url
 * @param headerMap
 * @param paramPartList
 * @return
 */
@Multipart
@POST
Call<ResponseBody> executeUpload(
        @Url String url,
        @HeaderMap Map<String, String> headerMap,
        @Part() List<MultipartBody.Part> paramPartList
);
 
Example 31
Project: Renrentou   File: RegService.java   Source Code and License 5 votes vote down vote up
@POST("user/regist/person")
@Multipart
Flowable<ResponseDto<User>> regPerson(
        @PartMap Map<String, RequestBody> param,
        @Part MultipartBody.Part front,
        @Part MultipartBody.Part back
);
 
Example 32
Project: Renrentou   File: AdService.java   Source Code and License 5 votes vote down vote up
@POST("ad/new")
@Multipart
Flowable<ResponseDto<User>> add(
        @PartMap Map<String, RequestBody> param,
        @Part MultipartBody.Part adFile,
        @Part MultipartBody.Part coverFile
);
 
Example 33
Project: Bigbang   File: OcrService.java   Source Code and License 5 votes vote down vote up
@Headers({
        "User-Agent: Mozilla/5.0",
        "accept-language:zh-CN,zh;q=0.8"
})
@Multipart// 参数的类型都应该是RequestBody,不然上传的图片的时候会报JSON must start with an array or an object错误
@POST("parse/image/")
Observable<OcrItem> uploadImage(@Part("apikey")String key , @Part("fileName") String description,
                         @Part("file\"; filename=\"image.png\"") RequestBody imgs);
 
Example 34
Project: retrofit-rxjava-request-with-progress   File: Api.java   Source Code and License 5 votes vote down vote up
@Multipart
@POST("pictureup/uploadshitu")
Observable<ProgressBean<String>> uploadPic(
        @Part("pos") String pos,
        @Part("uptype") String uptype,
        @Part("fm") String index,
        @Part("image\"; filename=\"xxx.jpg") File image
);
 
Example 35
Project: Plamber-Android   File: PlamberAPI.java   Source Code and License 5 votes vote down vote up
@Multipart
@POST("api/v1/upload-book/")
Call<Upload.UploadBookRespond> uploadFile(@Part("user_token") RequestBody userToken,
                                          @Part("book_name") RequestBody bookName,
                                          @Part("author") RequestBody authorName,
                                          @Part("category") RequestBody categoryName,
                                          @Part("about") RequestBody aboutBook,
                                          @Part("language") RequestBody languageBook,
                                          @Part("private_book") boolean private_book,
                                          @Part MultipartBody.Part file,
                                          @Part MultipartBody.Part cover);
 
Example 36
Project: richeditor   File: UploadHelper.java   Source Code and License 4 votes vote down vote up
public static MultipartBody.Part generateMultiPart(String parName,File file,RequestBodyWrapper uploadFileRequestBody){
    return MultipartBody.Part.createFormData(parName, file.getName(),uploadFileRequestBody);
}
 
Example 37
Project: ForeverLibrary   File: API.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST("api/upload/android")
Observable<BasicResponse<List<UploadModel>>> uploadFile(@Part("pic\"; filename=\"image1.png") RequestBody file);
 
Example 38
Project: richeditor   File: UploadHelper.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST
Observable<ResponseBody> uploadFile(@Url String url, @Part MultipartBody.Part file);
 
Example 39
Project: android-retrofit-image-upload   File: RetrofitInterface.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST("/images/upload")
Call<Response> uploadImage(@Part MultipartBody.Part image);
 
Example 40
Project: Bing   File: RestService.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST
Call<String> upload(@Url String url, @Part MultipartBody.Part file);
 
Example 41
Project: SuperHttp   File: ApiService.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST()
Observable<ResponseBody> uploadFiles(@Url() String url, @Part() List<MultipartBody.Part> parts);
 
Example 42
Project: BizareChat   File: ContentService.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST
@Xml
Observable<UploadFileResponse> uploadFile(@Url String url,
                                          @PartMap Map<String, RequestBody> params,
                                          @Part MultipartBody.Part file);
 
Example 43
Project: toshi-headless-client   File: IdInterface.java   Source Code and License 4 votes vote down vote up
@Multipart
@PUT("v1/user")
Call<User> uploadFile(@Part MultipartBody.Part file,
                        @Query("timestamp") long timestamp);
 
Example 44
Project: Clipcon-AndroidClient   File: RetrofitInterface.java   Source Code and License 4 votes vote down vote up
/** upload string data */
@Multipart
@Headers({ "User-Agent: androidProgram" })
@POST("UploadServlet")
Call<ResponseBody> requestStringDataUpload(@Part("userName") RequestBody username, @Part("groupPK") RequestBody grouppk, @Part("stringData") RequestBody stringdata);
 
Example 45
Project: Ec2m   File: RetrofitService.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST("mupload")
Call<ResponseBody> upload3(@Part("fileName") String description,
                          @PartMap Map<String,RequestBody> params);
 
Example 46
Project: Clipcon-AndroidClient   File: RetrofitInterface.java   Source Code and License 4 votes vote down vote up
/** upload file data */
@Multipart
@Headers({ "User-Agent: androidProgram"/*, "Content-RelativePath: /" */ })
@POST("UploadServlet")
Call<ResponseBody> requestFileDataUpload(@Part("userName") RequestBody username, @Part("groupPK") RequestBody grouppk, @Part MultipartBody.Part file);
 
Example 47
Project: yyox   File: AddressService.java   Source Code and License 4 votes vote down vote up
@Headers({HEADER_API_VERSION})
@Multipart
@POST("customer/address/uploadIDCard")
Observable<BaseJson<JsonObject>> uploadIdCard(@Part List<MultipartBody.Part> partList);
 
Example 48
Project: yyox   File: PackageService.java   Source Code and License 4 votes vote down vote up
@Headers({HEADER_API_VERSION})
@Multipart
@POST("inventory/receipt/upload")
Observable<BaseJson<JsonObject>> putPackageImage(@Part List< MultipartBody.Part> partList);
 
Example 49
Project: Phoenix-for-VK   File: IUploadService.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST
Call<UploadDocDto> uploadDocument(@Url String server, @Part MultipartBody.Part photo);
 
Example 50
Project: Phoenix-for-VK   File: IUploadService.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST
Call<UploadOwnerPhotoDto> uploadOwnerPhoto(@Url String server, @Part MultipartBody.Part photo);
 
Example 51
Project: Phoenix-for-VK   File: IUploadService.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST
Call<UploadPhotoToWallDto> uploadPhotoToWall(@Url String server, @Part MultipartBody.Part photo);
 
Example 52
Project: Phoenix-for-VK   File: IUploadService.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST
Call<UploadPhotoToMessageDto> uploadPhotoToMessage(@Url String server, @Part MultipartBody.Part photo);
 
Example 53
Project: Phoenix-for-VK   File: IUploadService.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST
Call<UploadPhotoToAlbumDto> uploadPhotoToAlbum(@Url String server, @Part MultipartBody.Part file1);
 
Example 54
Project: dracoon-dropzone   File: SdsService.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST(API_PATH + "/nodes/files/uploads/{upload_id}")
Call<Void> uploadFile(@Header(AUTHORIZATION_HEADER) String token,
                      @Path("upload_id") String uploadId,
                      @Part MultipartBody.Part file);
 
Example 55
Project: Artist   File: APIInterface.java   Source Code and License 4 votes vote down vote up
@POST("/compare/{id}")
@Multipart
Call<JsonElement> uploadImage(@Path("id")String id, @Part MultipartBody.Part file1);
 
Example 56
Project: Artist   File: APIInterface.java   Source Code and License 4 votes vote down vote up
@POST("/user")
@Multipart
Call<Void> saveUserData(@Part("phone")RequestBody phone, @Part("name")RequestBody name,
                        @Part("affiliation")RequestBody com, @Part("age")RequestBody age,
                        @Part("category")RequestBody category, @Part("score")RequestBody score, @Part MultipartBody.Part img);
 
Example 57
Project: Renrentou   File: FileUploadService.java   Source Code and License 4 votes vote down vote up
@POST("file//upload/v1")
@Multipart
Flowable<ResponseDto> add(
        @PartMap Map<String, RequestBody> param,
        @Part MultipartBody.Part file
);
 
Example 58
Project: Paper-Melody   File: SocialSystemAPI.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST("upload/musicfile")
Observable<UploadResponse> uploadMusicFile(@Part MultipartBody.Part file);
 
Example 59
Project: Renrentou   File: AdService.java   Source Code and License 4 votes vote down vote up
@POST("ad/new")
@Multipart
Flowable<ResponseDto<User>> add(
        @PartMap Map<String, RequestBody> param,
        @Part MultipartBody.Part adFile
);
 
Example 60
Project: ForeverLibrary   File: API.java   Source Code and License 4 votes vote down vote up
@Multipart
@POST("api/upload/android")
Observable<BasicResponse<List<UploadModel>>> uploadFile(@Part MultipartBody.Part file);