Package com.cloud.serverpak.handlers
Class FileHandler
java.lang.Object
com.cloud.serverpak.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 FilesInformServiceFile information service.private FileOutputStreamOutput stream to a file.private final MainHandlerNetty's main listener. -
Constructor Summary
ConstructorsConstructorDescriptionFileHandler(MainHandler mainHandler) The constructor saves the main listener reference. -
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
-
mainHandler
Netty's main listener.- See Also:
-
fileService
File information service.- See Also:
-
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 the main listener reference.- Parameters:
mainHandler- Netty's main listener.
-
-
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 the file. Sends a service message to the client with updated storage status data.- Parameters:
ctx- channel context.msg- the message object.- See Also:
-