forked from loafle/openapi-generator-original
@@ -467,7 +467,6 @@ public class ApiClient {
|
||||
for (Entry<String, Object> param: formParams.entrySet()) {
|
||||
if (param.getValue() instanceof File) {
|
||||
File file = (File) param.getValue();
|
||||
mp.field(param.getKey(), file.getName());
|
||||
mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE));
|
||||
} else {
|
||||
mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
|
||||
@@ -13,10 +13,9 @@ import javax.ws.rs.core.Response.Status;
|
||||
import org.glassfish.jersey.client.ClientConfig;
|
||||
import org.glassfish.jersey.filter.LoggingFilter;
|
||||
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
||||
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.MultiPart;
|
||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||
import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -478,23 +477,19 @@ public class ApiClient {
|
||||
Entity<?> formEntity = null;
|
||||
|
||||
if (contentType.startsWith("multipart/form-data")) {
|
||||
MultiPart multipart = new MultiPart();
|
||||
MultiPart multiPart = new MultiPart();
|
||||
for (Entry<String, Object> param: formParams.entrySet()) {
|
||||
if (param.getValue() instanceof File) {
|
||||
File file = (File) param.getValue();
|
||||
|
||||
FormDataMultiPart mp = new FormDataMultiPart();
|
||||
mp.bodyPart(new FormDataBodyPart(param.getKey(), file.getName()));
|
||||
multipart.bodyPart(mp, MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
|
||||
multipart.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.APPLICATION_OCTET_STREAM_TYPE));
|
||||
FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey())
|
||||
.fileName(file.getName()).size(file.length()).build();
|
||||
multiPart.bodyPart(new FormDataBodyPart(contentDisp, file, MediaType.APPLICATION_OCTET_STREAM_TYPE));
|
||||
} else {
|
||||
FormDataMultiPart mp = new FormDataMultiPart();
|
||||
mp.bodyPart(new FormDataBodyPart(param.getKey(), parameterToString(param.getValue())));
|
||||
multipart.bodyPart(mp, MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey()).build();
|
||||
multiPart.bodyPart(new FormDataBodyPart(contentDisp, parameterToString(param.getValue())));
|
||||
}
|
||||
}
|
||||
formEntity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
formEntity = Entity.entity(multiPart, MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||
} else if (contentType.startsWith("application/x-www-form-urlencoded")) {
|
||||
Form form = new Form();
|
||||
for (Entry<String, Object> param: formParams.entrySet()) {
|
||||
|
||||
Reference in New Issue
Block a user