Class FileHandler

java.lang.Object
com.cloud.clientpak.handlers.FileHandler

public class FileHandler extends Object
Class listener of messages carrying file data. Defines a method for work with a message containing the file data.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    Marker defining the mode of writing to the file (whether to append the data to the end of the file or overwrite it.)
    private final Controller
    Variable Controller
    Output stream to a file.
  • Constructor Summary

    Constructors
    Constructor
    Description
    FileHandler(Controller controller)
    The constructor saves a reference to the application controller.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    fileHandle(io.netty.channel.ChannelHandlerContext ctx, Object msg)
    Receives a message with file data, checks whether the file fits into 1 message.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • controller

      private final Controller controller
      Variable Controller
    • fos

      private FileOutputStream fos
      Output stream to a file.
    • append

      private boolean append
      Marker defining the mode of writing to the file (whether to append the data to the end of the file or overwrite it.)
  • Constructor Details

    • FileHandler

      public FileHandler(Controller controller)
      The constructor saves a reference to the application controller.
      Parameters:
      controller - application controller.
  • Method Details

    • fileHandle

      public void fileHandle(io.netty.channel.ChannelHandlerContext ctx, Object msg)
      Receives a message with file data, checks whether the file fits into 1 message. If not, then sets the "append" marker to "true" mode to record data from follow-up messages to the end of the file. After receiving the last part of the file in the message closes the output stream to a file, and sends a request to update the file list data
      Parameters:
      ctx - channel context.
      msg - message object.