Slavisa,

Since the Jetty component exposes an endpoint, there is no implicit assumption 
that the request will be a file so there is no built in functionality for this 
purpose. You can still determine the name of the file being uploaded as it is 
passed along in the request in the content-disposition HTTP header. You an use 
a bean to to parse the filename from this header and set another header that 
can be used in your file endpoint.

This reference[1] describes how you can parse the value out of the header.

Thanks,
Andy

[1] - https://docs.oracle.com/javaee/6/tutorial/doc/glraq.html

-- 
Andrew Block

On September 2, 2015 at 7:01:42 AM, s.marjanovic 
(slavisa.marjanovic...@gmail.com) wrote:

Hello,  

I'm creating a route that is supposed the accept an HTTP POST with a file  
and, among other things, archive that file. My route is as shown below:  

from("jetty:http://{{host}}?httpMethodRestrict=POST";).routeId("MyRoute")  
.to("file:"+"{{localArchiveFile}}")  
.unmarshal().zipFile()  
.convertBodyTo(String.class)  
.inOnly("amq:queue:MyQueue?timeToLive={{timetolive}}");  

Stream cache is enabled on camel context level.  

The problem I have is that file gets archived as something like ".134216472"  
(a dot plus current system time).  

Here's the filename pattern for inspection:  
/data/archive/?fileName=${date:now:yyyyMMdd}/${file:onlyname}.${date:now:HHmmssSSS}
  

I'd like to avoid this and save the file with it's original name with  
appended timestamp. I have inspected the exchange in debugger but I don't  
see the filename in in.headers or in.request. Is there a way that I'm  
missing that would enable me to get to the filename?  

Kind regards,  
Slavisa Marjanovic  






--  
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-get-the-file-name-from-an-http-post-submitted-to-jetty-endpoint-tp5771156.html
  
Sent from the Camel - Users mailing list archive at Nabble.com.  

Reply via email to