You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "jamesnetherton (via GitHub)" <gi...@apache.org> on 2023/09/21 11:26:32 UTC
[GitHub] [camel-quarkus] jamesnetherton opened a new pull request, #5328: Add multipart configuration options to servlet extension
jamesnetherton opened a new pull request, #5328:
URL: https://github.com/apache/camel-quarkus/pull/5328
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on a diff in pull request #5328: Add multipart configuration options to servlet extension
Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on code in PR #5328:
URL: https://github.com/apache/camel-quarkus/pull/5328#discussion_r1332924581
##########
extensions/servlet/runtime/src/main/java/org/apache/camel/quarkus/servlet/runtime/CamelServletConfig.java:
##########
@@ -87,6 +92,37 @@ public String getEffectiveServletName(final String key) {
return DEFAULT_SERVLET_NAME.equals(servletName) ? key : servletName;
}
+ /**
+ * Servlet multipart request configuration.
+ */
+ @ConfigGroup
+ public static class MultipartConfig {
+ /**
+ * An absolute path to a directory on the file system to store files temporarily while the parts are
+ * processed or when the size of the file exceeds the specified file-size-threshold configuration value.
+ */
+ @ConfigItem(defaultValue = "${java.io.tmpdir}")
+ public String location;
+
+ /**
+ * The maximum size allowed in bytes for uploaded files. The default size (-1) allows an unlimited size.
+ */
+ @ConfigItem(defaultValue = "-1")
+ public Optional<Long> maxFileSize;
+
+ /**
+ * The maximum size allowed in bytes for a multipart/form-data request. The default size (-1) allows an unlimited
+ * size.
+ */
+ @ConfigItem(defaultValue = "-1")
+ public Optional<Long> maxRequestSize;
+
+ /**
+ * The file size in bytes after which the file will be temporarily stored on disk.
+ */
+ @ConfigItem(defaultValue = "0")
+ public Optional<Integer> fileSizeThreshold;
Review Comment:
> The optionals will always be non-empty
I can remove the `Optional`.
> I also wonder why fileSizeThreshold is int while the others are long
See [MultipartConfigElement](https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/multipartconfigelement).
Guess I should also use primitives for the config options given that's how the corresponding options are defined in `MultipartConfigElement`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on pull request #5328: Add multipart configuration options to servlet extension
Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on PR #5328:
URL: https://github.com/apache/camel-quarkus/pull/5328#issuecomment-1734909313
Issues are hopefully resolved now. Turns out I cannot count properly. I had set the byte limit in the config props to less than what I was sending in the valid test scenarios.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on pull request #5328: Add multipart configuration options to servlet extension
Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on PR #5328:
URL: https://github.com/apache/camel-quarkus/pull/5328#issuecomment-1731178389
Setting the PR to draft as there's an odd issue happening on GitHub CI that I cannot replicate locally. Needs more investigation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] ppalaga commented on a diff in pull request #5328: Add multipart configuration options to servlet extension
Posted by "ppalaga (via GitHub)" <gi...@apache.org>.
ppalaga commented on code in PR #5328:
URL: https://github.com/apache/camel-quarkus/pull/5328#discussion_r1332918107
##########
extensions/servlet/runtime/src/main/java/org/apache/camel/quarkus/servlet/runtime/CamelServletConfig.java:
##########
@@ -87,6 +92,37 @@ public String getEffectiveServletName(final String key) {
return DEFAULT_SERVLET_NAME.equals(servletName) ? key : servletName;
}
+ /**
+ * Servlet multipart request configuration.
+ */
+ @ConfigGroup
+ public static class MultipartConfig {
+ /**
+ * An absolute path to a directory on the file system to store files temporarily while the parts are
+ * processed or when the size of the file exceeds the specified file-size-threshold configuration value.
+ */
+ @ConfigItem(defaultValue = "${java.io.tmpdir}")
+ public String location;
+
+ /**
+ * The maximum size allowed in bytes for uploaded files. The default size (-1) allows an unlimited size.
+ */
+ @ConfigItem(defaultValue = "-1")
+ public Optional<Long> maxFileSize;
+
+ /**
+ * The maximum size allowed in bytes for a multipart/form-data request. The default size (-1) allows an unlimited
+ * size.
+ */
+ @ConfigItem(defaultValue = "-1")
+ public Optional<Long> maxRequestSize;
+
+ /**
+ * The file size in bytes after which the file will be temporarily stored on disk.
+ */
+ @ConfigItem(defaultValue = "0")
+ public Optional<Integer> fileSizeThreshold;
Review Comment:
I wonder whether all these need be optional given that they all have defaults? The optionals will always be non-empty.
I also wonder why fileSizeThreshold is int while the others are long?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] ppalaga commented on a diff in pull request #5328: Add multipart configuration options to servlet extension
Posted by "ppalaga (via GitHub)" <gi...@apache.org>.
ppalaga commented on code in PR #5328:
URL: https://github.com/apache/camel-quarkus/pull/5328#discussion_r1332919453
##########
integration-tests/servlet/src/main/java/org/apache/camel/quarkus/component/servlet/MultiPartProcessor.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.servlet;
+
+import java.io.InputStream;
+
+import jakarta.inject.Singleton;
+import jakarta.servlet.http.HttpServletRequest;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+
+@Singleton
+public class MultiPartProcessor implements Processor {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ // TODO: Ideally AttachmentMessage would be used here instead of plain Servlet APIs
+ // https://issues.apache.org/jira/browse/CAMEL-19899
+ Message message = exchange.getMessage();
+ HttpServletRequest request = message.getHeader(Exchange.HTTP_SERVLET_REQUEST, HttpServletRequest.class);
+ InputStream file = request.getPart("file").getInputStream();
+ message.setBody(file.readAllBytes(), String.class);
Review Comment:
```suggestion
try (InputStream file = request.getPart("file").getInputStream()) {
message.setBody(file.readAllBytes(), String.class);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on a diff in pull request #5328: Add multipart configuration options to servlet extension
Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on code in PR #5328:
URL: https://github.com/apache/camel-quarkus/pull/5328#discussion_r1332924581
##########
extensions/servlet/runtime/src/main/java/org/apache/camel/quarkus/servlet/runtime/CamelServletConfig.java:
##########
@@ -87,6 +92,37 @@ public String getEffectiveServletName(final String key) {
return DEFAULT_SERVLET_NAME.equals(servletName) ? key : servletName;
}
+ /**
+ * Servlet multipart request configuration.
+ */
+ @ConfigGroup
+ public static class MultipartConfig {
+ /**
+ * An absolute path to a directory on the file system to store files temporarily while the parts are
+ * processed or when the size of the file exceeds the specified file-size-threshold configuration value.
+ */
+ @ConfigItem(defaultValue = "${java.io.tmpdir}")
+ public String location;
+
+ /**
+ * The maximum size allowed in bytes for uploaded files. The default size (-1) allows an unlimited size.
+ */
+ @ConfigItem(defaultValue = "-1")
+ public Optional<Long> maxFileSize;
+
+ /**
+ * The maximum size allowed in bytes for a multipart/form-data request. The default size (-1) allows an unlimited
+ * size.
+ */
+ @ConfigItem(defaultValue = "-1")
+ public Optional<Long> maxRequestSize;
+
+ /**
+ * The file size in bytes after which the file will be temporarily stored on disk.
+ */
+ @ConfigItem(defaultValue = "0")
+ public Optional<Integer> fileSizeThreshold;
Review Comment:
> The optionals will always be non-empty
I can remove the `Optional`.
> I also wonder why fileSizeThreshold is int while the others are long
See [MultipartConfigElement](https://jakarta.ee/specifications/servlet/5.0/apidocs/jakarta/servlet/multipartconfigelement).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] jamesnetherton commented on pull request #5328: Add multipart configuration options to servlet extension
Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on PR #5328:
URL: https://github.com/apache/camel-quarkus/pull/5328#issuecomment-1729453031
Latest commit should address review feedback.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add multipart configuration options to servlet extension [camel-quarkus]
Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton merged PR #5328:
URL: https://github.com/apache/camel-quarkus/pull/5328
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add multipart configuration options to servlet extension [camel-quarkus]
Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on PR #5328:
URL: https://github.com/apache/camel-quarkus/pull/5328#issuecomment-1973212311
To move this along I opened https://github.com/apache/camel-quarkus/issues/5830 to follow up on later.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org