public OutputStream openOutputStream(String name) throws FileResourceException { OutputStreamDataSource source = null; try { ftpClient.setPassive(); ftpClient.setLocalActive(); source = new OutputStreamDataSource(16384); TransferState state = ftpClient.asynchPut(name, source, null, false); state.waitForStart(); return source.getOutputStream(); } catch (Exception e) { if (source != null) { try { source.close(); } catch (IOException ee) { logger.warn("Failed to close FTP source", ee); } } throw translateException("Failed to open FTP stream", e); } }