{"record":{"id":"a537b169277b43d4","repo":"pentaho/pentaho-kettle","slug":"jobftps-error-writingtofile","errorCode":"JobFTPS.Error.WritingToFile","errorMessage":"JobFTPS.Error.WritingToFile","messagePattern":"JobFTPS\\.Error\\.WritingToFile","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/ftps/impl/src/main/java/org/pentaho/di/job/entries/ftpsget/FTPSConnection.java","lineNumber":447,"sourceCode":"   *\n   * @param file          remote file to download\n   * @param localFilename target filename\n   * @throws KettleException\n   */\n  public void downloadFile( FTPFile file, String localFilename ) throws KettleException {\n    try {\n      FileObject localFile = KettleVFS.getInstance( bowl ).getFileObject( localFilename, nameSpace );\n      writeToFile( connection.downloadStream( file ), localFile.getContent().getOutputStream(), localFilename );\n    } catch ( Exception e ) {\n      throw new KettleException( e );\n    }\n  }\n\n  private void writeToFile( InputStream is, OutputStream os, String filename ) throws KettleException {\n    try {\n      IOUtils.copy( is, os );\n    } catch ( IOException e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"JobFTPS.Error.WritingToFile\", filename ), e );\n    } finally {\n      IOUtils.closeQuietly( is );\n      IOUtils.closeQuietly( os );\n    }\n  }\n\n  /**\n   *\n   * this method is used to upload a file to a remote host\n   *\n   * @param localFileName\n   *          Local full filename\n   * @param shortFileName\n   *          Filename in remote host\n   * @throws KettleException\n   */\n  public void uploadFile( String localFileName, String shortFileName ) throws KettleException {\n    FileObject file = null;","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/ftps/impl/src/main/java/org/pentaho/di/job/entries/ftpsget/FTPSConnection.java#L429-L465","documentation":"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.","triggerScenarios":"downloadFile -> writeToFile when the local disk is full, the destination file cannot be written, or the remote input stream breaks mid-transfer (IOException)","commonSituations":"insufficient disk space on the machine running Pentaho; destination directory not writable; network interruption during a large download","solutions":["Check free disk space on the local filesystem","Verify write permissions on the local target directory/file","Retry the download; if it breaks repeatedly at the same offset, check network stability and passive-mode settings","Inspect the wrapped IOException cause for the exact OS-level error"],"exampleFix":"// before\nos = new FileOutputStream(localFile); // dir may not exist\n// after\nFile dir = localFile.getParentFile();\nif (dir != null) dir.mkdirs();\nos = new FileOutputStream(localFile);","handlingStrategy":"try-catch","validationCode":"File local = new File(targetPath);\nif (!local.getParentFile().canWrite() || local.getParentFile().getFreeSpace() < minBytes)\n  throw new IllegalStateException(\"local target not writable or low disk\");","typeGuard":null,"tryCatchPattern":"try {\n  connection.downloadFile(...);\n} catch (KettleException e) {\n  if (e.getCause() instanceof IOException) {\n    logError(\"Disk/IO problem writing \" + filename, e);\n  }\n  throw e;\n}","preventionTips":["Monitor free disk space before batch downloads","Ensure destination directories exist and are writable","Retry transient IO failures with backoff"],"tags":["ftps","io","file-download"],"backgroundTag":"file-write-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}