Merge branch 'patch-1' of https://github.com/kartenkarsten/swagger-codegen into kartenkarsten-patch-1

This commit is contained in:
wing328 2016-08-12 15:33:02 +08:00
commit 621dee30a8
2 changed files with 10 additions and 3 deletions

View File

@ -504,7 +504,7 @@ public class ApiClient {
for( File file : files ) {
mp.bodyPart( new FileDataBodyPart( param.getKey(), file, MediaType.APPLICATION_OCTET_STREAM_TYPE ) );
}
} elseif (param.getValue() instanceof File) {
} else if (param.getValue() instanceof File) {
File file = (File) param.getValue();
mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.APPLICATION_OCTET_STREAM_TYPE));
} else {

View File

@ -509,9 +509,16 @@ public class ApiClient {
if (contentType.startsWith("multipart/form-data")) {
FormDataMultiPart mp = new FormDataMultiPart();
for (Entry<String, Object> param: formParams.entrySet()) {
if (param.getValue() instanceof File) {
if( param.getValue() instanceof List && !( ( List ) param.getValue() ).isEmpty()
&& ( ( List ) param.getValue() ).get( 0 ) instanceof File ) {
@SuppressWarnings( "unchecked" )
List<File> files = ( List<File> ) param.getValue();
for( File file : files ) {
mp.bodyPart( new FileDataBodyPart( param.getKey(), file, MediaType.APPLICATION_OCTET_STREAM_TYPE ) );
}
} else if (param.getValue() instanceof File) {
File file = (File) param.getValue();
mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE));
mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.APPLICATION_OCTET_STREAM_TYPE));
} else {
mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE);
}