Package com.cloud.clientpak.handlers
Class FileHandler
java.lang.Object
com.cloud.clientpak.handlers.FileHandler
Class listener of messages carrying file data. Defines a method for work
with a message containing the file data.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanMarker defining the mode of writing to the file (whether to append the data to the end of the file or overwrite it.)private final ControllerVariableControllerprivate FileOutputStreamOutput stream to a file. -
Constructor Summary
ConstructorsConstructorDescriptionFileHandler(Controller controller) The constructor saves a reference to the application controller. -
Method Summary
Modifier and TypeMethodDescriptionvoidfileHandle(io.netty.channel.ChannelHandlerContext ctx, Object msg) Receives a message with file data, checks whether the file fits into 1 message.
-
Field Details
-
controller
VariableController -
fos
Output stream to a file. -
append
private boolean appendMarker 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
The constructor saves a reference to the application controller.- Parameters:
controller- application controller.
-
-
Method Details
-
fileHandle
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.
-