I played around with this a bit more and the reason that the file cannot be
displayed is because the file of course is being compressed. I updated my
last sample route from my previous query to add the Content-Encoding of gzip
to the Processor I created:

import java.io.File;
import java.util.Map;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;

public class FileProcessor implements Processor {

    public void process(Exchange exchange) throws Exception {
        String finalFile = "";

        finalFile = "/data/9b62405c463e6be04e6578ae129a6270.jpeg";
        File file = new File(finalFile);
        if (file.exists()) {
            exchange.getIn().setBody(file);
        } else {
            exchange.getIn().setBody("File does not exist");
        }
        exchange.getIn().setHeader("Content-Disposition",
"inline;filename*=UTF-8''9b62405c463e6be04e6578ae129a6270.jpeg");
        exchange.getIn().setHeader("Content-Type", "image/jpeg");
        exchange.getIn().setHeader("Content-Encoding", "gzip");
    }

}

The file is no displayable. I've a few questions here:

1) Why is the file being compressed?
2) When the file is compressed, why is an appropriate header, ie.
Content_Encoding, into the Exchange? That definitely sounds like a bug to
me.
3) Is there any way to turn off the compression of these files?



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-and-file-handling-tp5726797p5726959.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to