URLDecoder: Illegal hex characters in escape (%) pattern for multipart data
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am using multipart to fetch the pdf and object data from the service. I get the below error
java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters
in escape (%) pattern - For input string: "PD" at
java.net.URLDecoder.decode(URLDecoder.java:205) at
org.springframework.http.converter.FormHttpMessageConverter.read(FormHttpMessageConverter.java:186)
when invoking the service.
SERVICE :
@RequestMapping(value = "/getPDF", method = RequestMethod.GET,produces = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<MultiValueMap<String, Object>> getPDF(
@RequestParam String key,
HttpServletResponse response) {
MultiValueMap<String, Object> pdfResultMap = new LinkedMultiValueMap<String, Object>();
//Get the result
ByteArrayResource byteArrayResource = getPdf(); //Assign the PDF
//1) Build the first byte result
/* LinkedMultiValueMap<String, String> pdfMap = new LinkedMultiValueMap<>();
pdfMap.add("Content-disposition", "attachment;" );
pdfMap.add("Content-type", "application/pdf");*/
HttpHeaders xHeader2 = new HttpHeaders();
xHeader2.setContentType(MediaType.APPLICATION_PDF);
HttpEntity<ByteArrayResource> doc = new HttpEntity<ByteArrayResource>(byteArrayResource, xHeader2);
pdfResultMap.add("doc", doc);
// 2) Build the next
//Header
HttpHeaders xHeader = new HttpHeaders();
xHeader.setContentType(MediaType.APPLICATION_JSON);
// Get the result
Map<String, String> stringMap = new HashMap<String, String>();
//populate String map
HttpEntity<Map<String, String>> stringMapObject = new HttpEntity<Map<String, String>>(stringMap, xHeader);
pdfResultMap.add("stringMap", stringMapObject);
//3) Build the simple header
HttpHeaders xHeader1 = new HttpHeaders();
xHeader.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> titlePart = new HttpEntity<String>("pdftitle", xHeader1);
pdfResultMap.add("title", titlePart);
ResponseEntity<MultiValueMap<String, Object>> responseEntity = new ResponseEntity<MultiValueMap<String, Object>>(pdfResultMap, HttpStatus.OK);
return responseEntity;
}
CLIENT :
public getPdf() {
FormHttpMessageConverter formConverter = new FormHttpMessageConverter() {
@Override
public boolean canRead(Class<?> clazz, MediaType mediaType) {
if (clazz == MultiValueMap.class) {
return true;
}
return super.canRead(clazz, mediaType);
}
};
formConverter.setCharset(Charset.forName("UTF-8"));
List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
partConverters.add(new ByteArrayHttpMessageConverter());
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
stringHttpMessageConverter.setWriteAcceptCharset(false);
partConverters.add(stringHttpMessageConverter);
partConverters.add(new ResourceHttpMessageConverter());
formConverter.setPartConverters(partConverters);
restTemplate.getMessageConverters().add(formConverter);
ResponseEntity<MultiValueMap> response = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.GET,entity, MultiValueMap.class);
}
I Tried adding :
List<MediaType> a = new ArrayList<MediaType>();
a.add(MediaType.APPLICATION_OCTET_STREAM);
a.add(MediaType.MULTIPART_FORM_DATA);
a.add(new MediaType("application","pdf"));
formConverter.setSupportedMediaTypes(a);
But the same error .
Anything I am missing here?
java rest media-type
add a comment |
I am using multipart to fetch the pdf and object data from the service. I get the below error
java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters
in escape (%) pattern - For input string: "PD" at
java.net.URLDecoder.decode(URLDecoder.java:205) at
org.springframework.http.converter.FormHttpMessageConverter.read(FormHttpMessageConverter.java:186)
when invoking the service.
SERVICE :
@RequestMapping(value = "/getPDF", method = RequestMethod.GET,produces = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<MultiValueMap<String, Object>> getPDF(
@RequestParam String key,
HttpServletResponse response) {
MultiValueMap<String, Object> pdfResultMap = new LinkedMultiValueMap<String, Object>();
//Get the result
ByteArrayResource byteArrayResource = getPdf(); //Assign the PDF
//1) Build the first byte result
/* LinkedMultiValueMap<String, String> pdfMap = new LinkedMultiValueMap<>();
pdfMap.add("Content-disposition", "attachment;" );
pdfMap.add("Content-type", "application/pdf");*/
HttpHeaders xHeader2 = new HttpHeaders();
xHeader2.setContentType(MediaType.APPLICATION_PDF);
HttpEntity<ByteArrayResource> doc = new HttpEntity<ByteArrayResource>(byteArrayResource, xHeader2);
pdfResultMap.add("doc", doc);
// 2) Build the next
//Header
HttpHeaders xHeader = new HttpHeaders();
xHeader.setContentType(MediaType.APPLICATION_JSON);
// Get the result
Map<String, String> stringMap = new HashMap<String, String>();
//populate String map
HttpEntity<Map<String, String>> stringMapObject = new HttpEntity<Map<String, String>>(stringMap, xHeader);
pdfResultMap.add("stringMap", stringMapObject);
//3) Build the simple header
HttpHeaders xHeader1 = new HttpHeaders();
xHeader.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> titlePart = new HttpEntity<String>("pdftitle", xHeader1);
pdfResultMap.add("title", titlePart);
ResponseEntity<MultiValueMap<String, Object>> responseEntity = new ResponseEntity<MultiValueMap<String, Object>>(pdfResultMap, HttpStatus.OK);
return responseEntity;
}
CLIENT :
public getPdf() {
FormHttpMessageConverter formConverter = new FormHttpMessageConverter() {
@Override
public boolean canRead(Class<?> clazz, MediaType mediaType) {
if (clazz == MultiValueMap.class) {
return true;
}
return super.canRead(clazz, mediaType);
}
};
formConverter.setCharset(Charset.forName("UTF-8"));
List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
partConverters.add(new ByteArrayHttpMessageConverter());
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
stringHttpMessageConverter.setWriteAcceptCharset(false);
partConverters.add(stringHttpMessageConverter);
partConverters.add(new ResourceHttpMessageConverter());
formConverter.setPartConverters(partConverters);
restTemplate.getMessageConverters().add(formConverter);
ResponseEntity<MultiValueMap> response = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.GET,entity, MultiValueMap.class);
}
I Tried adding :
List<MediaType> a = new ArrayList<MediaType>();
a.add(MediaType.APPLICATION_OCTET_STREAM);
a.add(MediaType.MULTIPART_FORM_DATA);
a.add(new MediaType("application","pdf"));
formConverter.setSupportedMediaTypes(a);
But the same error .
Anything I am missing here?
java rest media-type
add a comment |
I am using multipart to fetch the pdf and object data from the service. I get the below error
java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters
in escape (%) pattern - For input string: "PD" at
java.net.URLDecoder.decode(URLDecoder.java:205) at
org.springframework.http.converter.FormHttpMessageConverter.read(FormHttpMessageConverter.java:186)
when invoking the service.
SERVICE :
@RequestMapping(value = "/getPDF", method = RequestMethod.GET,produces = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<MultiValueMap<String, Object>> getPDF(
@RequestParam String key,
HttpServletResponse response) {
MultiValueMap<String, Object> pdfResultMap = new LinkedMultiValueMap<String, Object>();
//Get the result
ByteArrayResource byteArrayResource = getPdf(); //Assign the PDF
//1) Build the first byte result
/* LinkedMultiValueMap<String, String> pdfMap = new LinkedMultiValueMap<>();
pdfMap.add("Content-disposition", "attachment;" );
pdfMap.add("Content-type", "application/pdf");*/
HttpHeaders xHeader2 = new HttpHeaders();
xHeader2.setContentType(MediaType.APPLICATION_PDF);
HttpEntity<ByteArrayResource> doc = new HttpEntity<ByteArrayResource>(byteArrayResource, xHeader2);
pdfResultMap.add("doc", doc);
// 2) Build the next
//Header
HttpHeaders xHeader = new HttpHeaders();
xHeader.setContentType(MediaType.APPLICATION_JSON);
// Get the result
Map<String, String> stringMap = new HashMap<String, String>();
//populate String map
HttpEntity<Map<String, String>> stringMapObject = new HttpEntity<Map<String, String>>(stringMap, xHeader);
pdfResultMap.add("stringMap", stringMapObject);
//3) Build the simple header
HttpHeaders xHeader1 = new HttpHeaders();
xHeader.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> titlePart = new HttpEntity<String>("pdftitle", xHeader1);
pdfResultMap.add("title", titlePart);
ResponseEntity<MultiValueMap<String, Object>> responseEntity = new ResponseEntity<MultiValueMap<String, Object>>(pdfResultMap, HttpStatus.OK);
return responseEntity;
}
CLIENT :
public getPdf() {
FormHttpMessageConverter formConverter = new FormHttpMessageConverter() {
@Override
public boolean canRead(Class<?> clazz, MediaType mediaType) {
if (clazz == MultiValueMap.class) {
return true;
}
return super.canRead(clazz, mediaType);
}
};
formConverter.setCharset(Charset.forName("UTF-8"));
List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
partConverters.add(new ByteArrayHttpMessageConverter());
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
stringHttpMessageConverter.setWriteAcceptCharset(false);
partConverters.add(stringHttpMessageConverter);
partConverters.add(new ResourceHttpMessageConverter());
formConverter.setPartConverters(partConverters);
restTemplate.getMessageConverters().add(formConverter);
ResponseEntity<MultiValueMap> response = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.GET,entity, MultiValueMap.class);
}
I Tried adding :
List<MediaType> a = new ArrayList<MediaType>();
a.add(MediaType.APPLICATION_OCTET_STREAM);
a.add(MediaType.MULTIPART_FORM_DATA);
a.add(new MediaType("application","pdf"));
formConverter.setSupportedMediaTypes(a);
But the same error .
Anything I am missing here?
java rest media-type
I am using multipart to fetch the pdf and object data from the service. I get the below error
java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters
in escape (%) pattern - For input string: "PD" at
java.net.URLDecoder.decode(URLDecoder.java:205) at
org.springframework.http.converter.FormHttpMessageConverter.read(FormHttpMessageConverter.java:186)
when invoking the service.
SERVICE :
@RequestMapping(value = "/getPDF", method = RequestMethod.GET,produces = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<MultiValueMap<String, Object>> getPDF(
@RequestParam String key,
HttpServletResponse response) {
MultiValueMap<String, Object> pdfResultMap = new LinkedMultiValueMap<String, Object>();
//Get the result
ByteArrayResource byteArrayResource = getPdf(); //Assign the PDF
//1) Build the first byte result
/* LinkedMultiValueMap<String, String> pdfMap = new LinkedMultiValueMap<>();
pdfMap.add("Content-disposition", "attachment;" );
pdfMap.add("Content-type", "application/pdf");*/
HttpHeaders xHeader2 = new HttpHeaders();
xHeader2.setContentType(MediaType.APPLICATION_PDF);
HttpEntity<ByteArrayResource> doc = new HttpEntity<ByteArrayResource>(byteArrayResource, xHeader2);
pdfResultMap.add("doc", doc);
// 2) Build the next
//Header
HttpHeaders xHeader = new HttpHeaders();
xHeader.setContentType(MediaType.APPLICATION_JSON);
// Get the result
Map<String, String> stringMap = new HashMap<String, String>();
//populate String map
HttpEntity<Map<String, String>> stringMapObject = new HttpEntity<Map<String, String>>(stringMap, xHeader);
pdfResultMap.add("stringMap", stringMapObject);
//3) Build the simple header
HttpHeaders xHeader1 = new HttpHeaders();
xHeader.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> titlePart = new HttpEntity<String>("pdftitle", xHeader1);
pdfResultMap.add("title", titlePart);
ResponseEntity<MultiValueMap<String, Object>> responseEntity = new ResponseEntity<MultiValueMap<String, Object>>(pdfResultMap, HttpStatus.OK);
return responseEntity;
}
CLIENT :
public getPdf() {
FormHttpMessageConverter formConverter = new FormHttpMessageConverter() {
@Override
public boolean canRead(Class<?> clazz, MediaType mediaType) {
if (clazz == MultiValueMap.class) {
return true;
}
return super.canRead(clazz, mediaType);
}
};
formConverter.setCharset(Charset.forName("UTF-8"));
List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
partConverters.add(new ByteArrayHttpMessageConverter());
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
stringHttpMessageConverter.setWriteAcceptCharset(false);
partConverters.add(stringHttpMessageConverter);
partConverters.add(new ResourceHttpMessageConverter());
formConverter.setPartConverters(partConverters);
restTemplate.getMessageConverters().add(formConverter);
ResponseEntity<MultiValueMap> response = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.GET,entity, MultiValueMap.class);
}
I Tried adding :
List<MediaType> a = new ArrayList<MediaType>();
a.add(MediaType.APPLICATION_OCTET_STREAM);
a.add(MediaType.MULTIPART_FORM_DATA);
a.add(new MediaType("application","pdf"));
formConverter.setSupportedMediaTypes(a);
But the same error .
Anything I am missing here?
SERVICE :
@RequestMapping(value = "/getPDF", method = RequestMethod.GET,produces = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<MultiValueMap<String, Object>> getPDF(
@RequestParam String key,
HttpServletResponse response) {
MultiValueMap<String, Object> pdfResultMap = new LinkedMultiValueMap<String, Object>();
//Get the result
ByteArrayResource byteArrayResource = getPdf(); //Assign the PDF
//1) Build the first byte result
/* LinkedMultiValueMap<String, String> pdfMap = new LinkedMultiValueMap<>();
pdfMap.add("Content-disposition", "attachment;" );
pdfMap.add("Content-type", "application/pdf");*/
HttpHeaders xHeader2 = new HttpHeaders();
xHeader2.setContentType(MediaType.APPLICATION_PDF);
HttpEntity<ByteArrayResource> doc = new HttpEntity<ByteArrayResource>(byteArrayResource, xHeader2);
pdfResultMap.add("doc", doc);
// 2) Build the next
//Header
HttpHeaders xHeader = new HttpHeaders();
xHeader.setContentType(MediaType.APPLICATION_JSON);
// Get the result
Map<String, String> stringMap = new HashMap<String, String>();
//populate String map
HttpEntity<Map<String, String>> stringMapObject = new HttpEntity<Map<String, String>>(stringMap, xHeader);
pdfResultMap.add("stringMap", stringMapObject);
//3) Build the simple header
HttpHeaders xHeader1 = new HttpHeaders();
xHeader.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> titlePart = new HttpEntity<String>("pdftitle", xHeader1);
pdfResultMap.add("title", titlePart);
ResponseEntity<MultiValueMap<String, Object>> responseEntity = new ResponseEntity<MultiValueMap<String, Object>>(pdfResultMap, HttpStatus.OK);
return responseEntity;
}
CLIENT :
public getPdf() {
FormHttpMessageConverter formConverter = new FormHttpMessageConverter() {
@Override
public boolean canRead(Class<?> clazz, MediaType mediaType) {
if (clazz == MultiValueMap.class) {
return true;
}
return super.canRead(clazz, mediaType);
}
};
formConverter.setCharset(Charset.forName("UTF-8"));
List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
partConverters.add(new ByteArrayHttpMessageConverter());
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
stringHttpMessageConverter.setWriteAcceptCharset(false);
partConverters.add(stringHttpMessageConverter);
partConverters.add(new ResourceHttpMessageConverter());
formConverter.setPartConverters(partConverters);
restTemplate.getMessageConverters().add(formConverter);
ResponseEntity<MultiValueMap> response = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.GET,entity, MultiValueMap.class);
}
I Tried adding :
List<MediaType> a = new ArrayList<MediaType>();
a.add(MediaType.APPLICATION_OCTET_STREAM);
a.add(MediaType.MULTIPART_FORM_DATA);
a.add(new MediaType("application","pdf"));
formConverter.setSupportedMediaTypes(a);
But the same error .
SERVICE :
@RequestMapping(value = "/getPDF", method = RequestMethod.GET,produces = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<MultiValueMap<String, Object>> getPDF(
@RequestParam String key,
HttpServletResponse response) {
MultiValueMap<String, Object> pdfResultMap = new LinkedMultiValueMap<String, Object>();
//Get the result
ByteArrayResource byteArrayResource = getPdf(); //Assign the PDF
//1) Build the first byte result
/* LinkedMultiValueMap<String, String> pdfMap = new LinkedMultiValueMap<>();
pdfMap.add("Content-disposition", "attachment;" );
pdfMap.add("Content-type", "application/pdf");*/
HttpHeaders xHeader2 = new HttpHeaders();
xHeader2.setContentType(MediaType.APPLICATION_PDF);
HttpEntity<ByteArrayResource> doc = new HttpEntity<ByteArrayResource>(byteArrayResource, xHeader2);
pdfResultMap.add("doc", doc);
// 2) Build the next
//Header
HttpHeaders xHeader = new HttpHeaders();
xHeader.setContentType(MediaType.APPLICATION_JSON);
// Get the result
Map<String, String> stringMap = new HashMap<String, String>();
//populate String map
HttpEntity<Map<String, String>> stringMapObject = new HttpEntity<Map<String, String>>(stringMap, xHeader);
pdfResultMap.add("stringMap", stringMapObject);
//3) Build the simple header
HttpHeaders xHeader1 = new HttpHeaders();
xHeader.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> titlePart = new HttpEntity<String>("pdftitle", xHeader1);
pdfResultMap.add("title", titlePart);
ResponseEntity<MultiValueMap<String, Object>> responseEntity = new ResponseEntity<MultiValueMap<String, Object>>(pdfResultMap, HttpStatus.OK);
return responseEntity;
}
CLIENT :
public getPdf() {
FormHttpMessageConverter formConverter = new FormHttpMessageConverter() {
@Override
public boolean canRead(Class<?> clazz, MediaType mediaType) {
if (clazz == MultiValueMap.class) {
return true;
}
return super.canRead(clazz, mediaType);
}
};
formConverter.setCharset(Charset.forName("UTF-8"));
List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
partConverters.add(new ByteArrayHttpMessageConverter());
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
stringHttpMessageConverter.setWriteAcceptCharset(false);
partConverters.add(stringHttpMessageConverter);
partConverters.add(new ResourceHttpMessageConverter());
formConverter.setPartConverters(partConverters);
restTemplate.getMessageConverters().add(formConverter);
ResponseEntity<MultiValueMap> response = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.GET,entity, MultiValueMap.class);
}
I Tried adding :
List<MediaType> a = new ArrayList<MediaType>();
a.add(MediaType.APPLICATION_OCTET_STREAM);
a.add(MediaType.MULTIPART_FORM_DATA);
a.add(new MediaType("application","pdf"));
formConverter.setSupportedMediaTypes(a);
But the same error .
java rest media-type
java rest media-type
edited Nov 16 '18 at 15:56
secret super star
1,040316
1,040316
asked Nov 16 '18 at 15:27
stackuserstackuser
1,46831421
1,46831421
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You try to read from FormHttpMessageConverter but the doc https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/converter/FormHttpMessageConverter.html says
"In other words, this converter can read and write the "application/x-www-form-urlencoded" media type as MultiValueMap and it can also write (but not read) the "multipart/form-data" media type as MultiValueMap."
Thanks Maksim. I did not know that. Is there any other way to send the byte stream and object to the client from the service? apart from converting to base 64?
– stackuser
Nov 16 '18 at 16:00
I think there is no way to avoid the usage of the org.springframework.web.multipart package .
– Maksim
Nov 16 '18 at 16:25
Thanks Maksim. Is there an example for this ?
– stackuser
Nov 16 '18 at 16:53
"Use the source (of docs), Luke": spring.io/guides/gs/uploading-files
– Maksim
Nov 16 '18 at 16:56
1
Thanks Maksim. Looks like even that supports File Upload and not download a file and an object together. I will consider base64
– stackuser
Nov 16 '18 at 16:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340819%2furldecoder-illegal-hex-characters-in-escape-pattern-for-multipart-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You try to read from FormHttpMessageConverter but the doc https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/converter/FormHttpMessageConverter.html says
"In other words, this converter can read and write the "application/x-www-form-urlencoded" media type as MultiValueMap and it can also write (but not read) the "multipart/form-data" media type as MultiValueMap."
Thanks Maksim. I did not know that. Is there any other way to send the byte stream and object to the client from the service? apart from converting to base 64?
– stackuser
Nov 16 '18 at 16:00
I think there is no way to avoid the usage of the org.springframework.web.multipart package .
– Maksim
Nov 16 '18 at 16:25
Thanks Maksim. Is there an example for this ?
– stackuser
Nov 16 '18 at 16:53
"Use the source (of docs), Luke": spring.io/guides/gs/uploading-files
– Maksim
Nov 16 '18 at 16:56
1
Thanks Maksim. Looks like even that supports File Upload and not download a file and an object together. I will consider base64
– stackuser
Nov 16 '18 at 16:59
add a comment |
You try to read from FormHttpMessageConverter but the doc https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/converter/FormHttpMessageConverter.html says
"In other words, this converter can read and write the "application/x-www-form-urlencoded" media type as MultiValueMap and it can also write (but not read) the "multipart/form-data" media type as MultiValueMap."
Thanks Maksim. I did not know that. Is there any other way to send the byte stream and object to the client from the service? apart from converting to base 64?
– stackuser
Nov 16 '18 at 16:00
I think there is no way to avoid the usage of the org.springframework.web.multipart package .
– Maksim
Nov 16 '18 at 16:25
Thanks Maksim. Is there an example for this ?
– stackuser
Nov 16 '18 at 16:53
"Use the source (of docs), Luke": spring.io/guides/gs/uploading-files
– Maksim
Nov 16 '18 at 16:56
1
Thanks Maksim. Looks like even that supports File Upload and not download a file and an object together. I will consider base64
– stackuser
Nov 16 '18 at 16:59
add a comment |
You try to read from FormHttpMessageConverter but the doc https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/converter/FormHttpMessageConverter.html says
"In other words, this converter can read and write the "application/x-www-form-urlencoded" media type as MultiValueMap and it can also write (but not read) the "multipart/form-data" media type as MultiValueMap."
You try to read from FormHttpMessageConverter but the doc https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/converter/FormHttpMessageConverter.html says
"In other words, this converter can read and write the "application/x-www-form-urlencoded" media type as MultiValueMap and it can also write (but not read) the "multipart/form-data" media type as MultiValueMap."
answered Nov 16 '18 at 15:36
MaksimMaksim
46648
46648
Thanks Maksim. I did not know that. Is there any other way to send the byte stream and object to the client from the service? apart from converting to base 64?
– stackuser
Nov 16 '18 at 16:00
I think there is no way to avoid the usage of the org.springframework.web.multipart package .
– Maksim
Nov 16 '18 at 16:25
Thanks Maksim. Is there an example for this ?
– stackuser
Nov 16 '18 at 16:53
"Use the source (of docs), Luke": spring.io/guides/gs/uploading-files
– Maksim
Nov 16 '18 at 16:56
1
Thanks Maksim. Looks like even that supports File Upload and not download a file and an object together. I will consider base64
– stackuser
Nov 16 '18 at 16:59
add a comment |
Thanks Maksim. I did not know that. Is there any other way to send the byte stream and object to the client from the service? apart from converting to base 64?
– stackuser
Nov 16 '18 at 16:00
I think there is no way to avoid the usage of the org.springframework.web.multipart package .
– Maksim
Nov 16 '18 at 16:25
Thanks Maksim. Is there an example for this ?
– stackuser
Nov 16 '18 at 16:53
"Use the source (of docs), Luke": spring.io/guides/gs/uploading-files
– Maksim
Nov 16 '18 at 16:56
1
Thanks Maksim. Looks like even that supports File Upload and not download a file and an object together. I will consider base64
– stackuser
Nov 16 '18 at 16:59
Thanks Maksim. I did not know that. Is there any other way to send the byte stream and object to the client from the service? apart from converting to base 64?
– stackuser
Nov 16 '18 at 16:00
Thanks Maksim. I did not know that. Is there any other way to send the byte stream and object to the client from the service? apart from converting to base 64?
– stackuser
Nov 16 '18 at 16:00
I think there is no way to avoid the usage of the org.springframework.web.multipart package .
– Maksim
Nov 16 '18 at 16:25
I think there is no way to avoid the usage of the org.springframework.web.multipart package .
– Maksim
Nov 16 '18 at 16:25
Thanks Maksim. Is there an example for this ?
– stackuser
Nov 16 '18 at 16:53
Thanks Maksim. Is there an example for this ?
– stackuser
Nov 16 '18 at 16:53
"Use the source (of docs), Luke": spring.io/guides/gs/uploading-files
– Maksim
Nov 16 '18 at 16:56
"Use the source (of docs), Luke": spring.io/guides/gs/uploading-files
– Maksim
Nov 16 '18 at 16:56
1
1
Thanks Maksim. Looks like even that supports File Upload and not download a file and an object together. I will consider base64
– stackuser
Nov 16 '18 at 16:59
Thanks Maksim. Looks like even that supports File Upload and not download a file and an object together. I will consider base64
– stackuser
Nov 16 '18 at 16:59
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340819%2furldecoder-illegal-hex-characters-in-escape-pattern-for-multipart-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown