Class FileBufferCommand

java.lang.Object
com.streamconverter.command.AbstractStreamCommand
com.streamconverter.command.impl.FileBufferCommand
All Implemented Interfaces:
IStreamCommand

A pipeline command that buffers data through a temporary file between pipeline stages.

This command solves the problem where validation failures in a preceding stage can cause invalid data to be written to the output stream. By buffering through a temporary file, the upstream stage completes fully before the downstream stage begins, ensuring data integrity.

Usage example:


 StreamConverter.create(
     validateCmd,
     FileBufferCommand.create(),
     transformCmd
 );
 

The encrypted variant (createEncrypted()) uses AES-256-GCM to protect sensitive data written to the temporary file.

  • Method Details

    • create

      public static FileBufferCommand create()
      Creates a FileBufferCommand that buffers data through a plaintext temporary file.
      Returns:
      a new FileBufferCommand instance
    • createEncrypted

      Creates a FileBufferCommand that buffers data through an AES-256-GCM encrypted temporary file.

      The encryption key and IV are generated per execution and never persisted, providing confidentiality for sensitive pipeline data.

      Returns:
      a new FileBufferCommand instance with encryption enabled
    • execute

      public void execute(InputStream inputStream, OutputStream outputStream) throws IOException
      Executes the buffering operation: writes the input stream to a temporary file, then reads the temporary file to the output stream.
      Specified by:
      execute in interface IStreamCommand
      Specified by:
      execute in class AbstractStreamCommand
      Parameters:
      inputStream - the input stream to read data from
      outputStream - the output stream to write data to
      Throws:
      IOException - if an I/O error occurs, or if decryption authentication fails