This is an automated email from the ASF dual-hosted git repository.
fmariani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new 2c0d67f9f87 Add more headers in platform-http multipart uploads
2c0d67f9f87 is described below
commit 2c0d67f9f87028ecbd611243f79ba56e8be92a9f
Author: Croway <[email protected]>
AuthorDate: Wed Feb 5 15:02:02 2025 +0100
Add more headers in platform-http multipart uploads
---
.../platform/http/springboot/SpringBootPlatformHttpBinding.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git
a/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/SpringBootPlatformHttpBinding.java
b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/SpringBootPlatformHttpBinding.java
index ba5280bba8a..0530638ffe8 100644
---
a/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/SpringBootPlatformHttpBinding.java
+++
b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/SpringBootPlatformHttpBinding.java
@@ -99,6 +99,7 @@ public class SpringBootPlatformHttpBinding extends
DefaultHttpBinding {
File tmpFolder = (File)
request.getServletContext().getAttribute(ServletContext.TEMPDIR);
boolean isSingleAttachment =
multipartHttpServletRequest.getFileMap() != null &&
multipartHttpServletRequest.getFileMap().keySet().size()
== 1;
+ message.setHeader(Exchange.ATTACHMENTS_SIZE,
multipartHttpServletRequest.getFileMap().keySet().size());
multipartHttpServletRequest.getFileMap().forEach((name,
multipartFile) -> {
try {
Path uploadedTmpFile = Paths.get(tmpFolder.getPath(),
UUID.randomUUID().toString());
@@ -122,13 +123,16 @@ public class SpringBootPlatformHttpBinding extends
DefaultHttpBinding {
if (accepted) {
AttachmentMessage am =
message.getExchange().getMessage(AttachmentMessage.class);
- am.addAttachment(name, new DataHandler(new
CamelFileDataSource(uploadedTmpFile.toFile(), name)));
+ File uploadedFile = uploadedTmpFile.toFile();
+ am.addAttachment(name, new DataHandler(new
CamelFileDataSource(uploadedFile, name)));
// populate body in case there is only one attachment
if (isSingleAttachment) {
+ message.setHeader(Exchange.FILE_PATH,
uploadedFile.getAbsolutePath());
+ message.setHeader(Exchange.FILE_LENGTH,
multipartFile.getSize());
message.setHeader(Exchange.FILE_NAME,
multipartFile.getOriginalFilename());
if (multipartFile.getContentType() != null) {
- message.setHeader(Exchange.CONTENT_TYPE,
multipartFile.getContentType());
+ message.setHeader(Exchange.FILE_CONTENT_TYPE,
multipartFile.getContentType());
}
message.setBody(uploadedTmpFile);
}