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);
    }
  }
  public InputStream openInputStream(String name) throws FileResourceException {
    InputStreamDataSink sink = null;
    try {
      ftpClient.setPassive();
      ftpClient.setLocalActive();

      sink = new InputStreamDataSink();

      TransferState state = ftpClient.asynchGet(name, sink, null);
      state.waitForStart();

      return sink.getInputStream();
    } catch (Exception e) {
      if (sink != null) {
        try {
          sink.close();
        } catch (IOException ee) {
          logger.warn("Failed to close FTP sink", ee);
        }
      }
      throw translateException("Failed to open FTP stream", e);
    }
  }