Hi Bengt.

Yes, I'm able to specify a subfolder in my URI.
As far as I can see, it works fine as a producer if I specify a subfolder.

What I have ended up doing is:

from("ftp://host.com?password=tiktak&binary=true&consumer.delay=10000&recursive=true";)
                .to("file://inbox");
        from("file://inbox?recursive=true&idempotent=true")
                .process(
                new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
                String resourceID="";
                JSONArray ja=new JSONArray();
                
                GenericFile body = (GenericFile) exchange.getIn().getBody();
                File f = (File) body.getFile();
                try (FileInputStream is = new FileInputStream(f)) {
                    BufferedReader br = new BufferedReader(new
InputStreamReader(is));
                    
                    if(f.getName().equals("bbr.csv")){
                        resourceID="";
                    }else{
                        resourceID="";
                    }
                    
                    String[] headlines=null; 
                    String[] datalines=null; 
                    String strLine;
                    int i=0;
                    while ((strLine = br.readLine()) != null) {
                        if(i==0){
                            headlines=strLine.split(",");
                        }else{
                            datalines=strLine.split(",");
                            JSONObject jo=new JSONObject();
                            for (int j=0; j<headlines.length;j++){
                                jo.put(headlines[j],datalines[j]);
                            }
                            ja.put(jo);
                        }
                        i++;
                    }
                }
               
exchange.getIn().setBody("{\"resource_id\":\""+resourceID+"\", \"records\":
" + ja.toString() + ",\"method\":\"insert\"}");
            }
        }).setHeader("CamelHttpMethod", constant("POST"))
         .setHeader("Authorization", constant("somenumbers"))
         .to("http4://somehost");

I havent tested the above code fully yet, but I think it work :-). Anyways,
this is how I solve my problem, and I just want to show my code, so anyone
with similar tasks can get inspiration.

Thanks for your quick responses and help guys.

Regards



--
View this message in context: 
http://camel.465427.n5.nabble.com/Cannot-change-directory-to-Code-550-on-FTP-component-tp5734612p5734725.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to