Skip to content

Commit

Permalink
Merge pull request #1187 from jim-krueger/1186-Fix_multipart_example
Browse files Browse the repository at this point in the history
Fix multipart example with addition of GenericEntity
  • Loading branch information
jim-krueger authored Feb 27, 2024
2 parents 95d7290 + 6169df2 commit d4e9ca4
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************
* Copyright (c) 2021 Eclipse Foundation
* Copyright (c) 2021, 2023 Eclipse Foundation
*
* This specification document is made available under the terms
* of the Eclipse Foundation Specification License v1.0, which is
Expand All @@ -22,6 +22,7 @@
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.EntityPart;
import jakarta.ws.rs.core.GenericEntity;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
Expand All @@ -34,7 +35,7 @@ public boolean sendPdfs(Path dir) throws IOException {
List<EntityPart> parts = Files.list(dir).map(this::toPart).collect(Collectors.toList());
Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://localhost:9080/multipart?dirName=abc");
Entity<List<EntityPart>> entity = Entity.entity(parts, MediaType.MULTIPART_FORM_DATA);
Entity<GenericEntity<List<EntityPart>>> entity = Entity.entity(new GenericEntity<>(parts) { }, MediaType.MULTIPART_FORM_DATA);
Response response = target.request().post(entity);
return response.getStatus() == 200;
}
Expand Down

0 comments on commit d4e9ca4

Please sign in to comment.