public void writeFile(Exchange exchange, String fileName) throws GenericFileOperationFailedException { // build directory if auto create is enabled if (endpoint.isAutoCreate()) { // we must normalize it (to avoid having both \ and / in the name which confuses java.io.File) String name = FileUtil.normalizePath(fileName); // use java.io.File to compute the file path File file = new File(name); String directory = file.getParent(); boolean absolute = FileUtil.isAbsolute(file); if (directory != null) { if (!operations.buildDirectory(directory, absolute)) { log.debug( "Cannot build directory [{}] (could be because of denied permissions)", directory); } } } // upload if (log.isTraceEnabled()) { log.trace( "About to write [{}] to [{}] from exchange [{}]", new Object[] {fileName, getEndpoint(), exchange}); } boolean success = operations.storeFile(fileName, exchange); if (!success) { throw new GenericFileOperationFailedException("Error writing file [" + fileName + "]"); } log.debug("Wrote [{}] to [{}]", fileName, getEndpoint()); }