pentaho/pentaho-kettle · error · KettleException

JobFTPS.Error.WritingToFile

JobFTPS.Error.WritingToFile

Error message

JobFTPS.Error.WritingToFile

What it means

KettleException thrown by the private writeToFile helper when IOUtils.copy fails while streaming a downloaded FTPS file to a local output stream. Both streams are closed in the finally block regardless.

Solutions

  1. Check free disk space on the local filesystem
  2. Verify write permissions on the local target directory/file
  3. Retry the download; if it breaks repeatedly at the same offset, check network stability and passive-mode settings
  4. Inspect the wrapped IOException cause for the exact OS-level error

Example fix

// before
os = new FileOutputStream(localFile); // dir may not exist
// after
File dir = localFile.getParentFile();
if (dir != null) dir.mkdirs();
os = new FileOutputStream(localFile);
Defensive patterns

Strategy: try-catch

Validate before calling

File local = new File(targetPath);
if (!local.getParentFile().canWrite() || local.getParentFile().getFreeSpace() < minBytes)
  throw new IllegalStateException("local target not writable or low disk");

Try / catch

try {
  connection.downloadFile(...);
} catch (KettleException e) {
  if (e.getCause() instanceof IOException) {
    logError("Disk/IO problem writing " + filename, e);
  }
  throw e;
}

Prevention

When it happens

Trigger: downloadFile -> writeToFile when the local disk is full, the destination file cannot be written, or the remote input stream breaks mid-transfer (IOException)

Common situations: insufficient disk space on the machine running Pentaho; destination directory not writable; network interruption during a large download

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/a537b169277b43d4. Report an issue: GitHub.

Appendix: source

Thrown at plugins/ftps/impl/src/main/java/org/pentaho/di/job/entries/ftpsget/FTPSConnection.java:447

   *
   * @param file          remote file to download
   * @param localFilename target filename
   * @throws KettleException
   */
  public void downloadFile( FTPFile file, String localFilename ) throws KettleException {
    try {
      FileObject localFile = KettleVFS.getInstance( bowl ).getFileObject( localFilename, nameSpace );
      writeToFile( connection.downloadStream( file ), localFile.getContent().getOutputStream(), localFilename );
    } catch ( Exception e ) {
      throw new KettleException( e );
    }
  }

  private void writeToFile( InputStream is, OutputStream os, String filename ) throws KettleException {
    try {
      IOUtils.copy( is, os );
    } catch ( IOException e ) {
      throw new KettleException( BaseMessages.getString( PKG, "JobFTPS.Error.WritingToFile", filename ), e );
    } finally {
      IOUtils.closeQuietly( is );
      IOUtils.closeQuietly( os );
    }
  }

  /**
   *
   * this method is used to upload a file to a remote host
   *
   * @param localFileName
   *          Local full filename
   * @param shortFileName
   *          Filename in remote host
   * @throws KettleException
   */
  public void uploadFile( String localFileName, String shortFileName ) throws KettleException {
    FileObject file = null;

View on GitHub (pinned to f3058517a1)