Skip to content

Commit

Permalink
Fix multipart example with addition of GenericEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-krueger committed Oct 13, 2023
1 parent 77e78fc commit 6169df2
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 6169df2

Please sign in to comment.