如何使用 camel-jetty 组件上传图片
How to upload image using camel-jetty component
我正在使用 camel-jetty 组件创建图像文件上传器。图片将作为多部分表单数据附加在请求正文中,并且必须上传到 S3。
这是我的路线: from("jetty:http://localhost:8889/imageservice?enableMultipartFilter=true").process(processor);
但是在请求到达处理器之前,它会抛出以下异常。我在 google 中搜索但一无所获。请帮我解决这个问题。
org.apache.camel.RuntimeCamelException: Cannot populate attachments
at org.apache.camel.component.jetty9.AttachmentHttpBinding.populateAttachments(AttachmentHttpBinding.java:56)
at org.apache.camel.http.common.DefaultHttpBinding.readRequest(DefaultHttpBinding.java:175)
at org.apache.camel.http.common.HttpMessage.<init>(HttpMessage.java:52)
at org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:134)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
at org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:200)
at org.apache.camel.component.jetty.CamelFilterWrapper.doFilter(CamelFilterWrapper.java:43)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection.run(AbstractConnection.java:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at org.apache.camel.component.jetty9.AttachmentHttpBinding.populateAttachments(AttachmentHttpBinding.java:48)
... 22 more
遵循 NullPointerException 堆栈跟踪...当 org.eclipse.jetty.util.MultiPartInputStreamParser 将请求解析为多个部分时,其中一个部分为空。这表明请求的格式有问题...
尝试在码头 url 上将 属性 'disableStreamCache' 设置为 true。每 http://camel.apache.org/jetty、"By default Camel will cache the Jetty input stream to support reading it multiple times to ensure it Camel can retrieve all data from the stream. However you can set this option to true when you for example need to access the raw stream, such as streaming it directly to a file or other persistent store."
我正在使用 camel-jetty 组件创建图像文件上传器。图片将作为多部分表单数据附加在请求正文中,并且必须上传到 S3。
这是我的路线: from("jetty:http://localhost:8889/imageservice?enableMultipartFilter=true").process(processor);
但是在请求到达处理器之前,它会抛出以下异常。我在 google 中搜索但一无所获。请帮我解决这个问题。
org.apache.camel.RuntimeCamelException: Cannot populate attachments
at org.apache.camel.component.jetty9.AttachmentHttpBinding.populateAttachments(AttachmentHttpBinding.java:56)
at org.apache.camel.http.common.DefaultHttpBinding.readRequest(DefaultHttpBinding.java:175)
at org.apache.camel.http.common.HttpMessage.<init>(HttpMessage.java:52)
at org.apache.camel.component.jetty.CamelContinuationServlet.service(CamelContinuationServlet.java:134)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
at org.eclipse.jetty.servlets.MultiPartFilter.doFilter(MultiPartFilter.java:200)
at org.apache.camel.component.jetty.CamelFilterWrapper.doFilter(CamelFilterWrapper.java:43)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection.run(AbstractConnection.java:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at org.apache.camel.component.jetty9.AttachmentHttpBinding.populateAttachments(AttachmentHttpBinding.java:48)
... 22 more
遵循 NullPointerException 堆栈跟踪...当 org.eclipse.jetty.util.MultiPartInputStreamParser 将请求解析为多个部分时,其中一个部分为空。这表明请求的格式有问题...
尝试在码头 url 上将 属性 'disableStreamCache' 设置为 true。每 http://camel.apache.org/jetty、"By default Camel will cache the Jetty input stream to support reading it multiple times to ensure it Camel can retrieve all data from the stream. However you can set this option to true when you for example need to access the raw stream, such as streaming it directly to a file or other persistent store."