Answer the question
In order to leave comments, you need to log in
How to transfer image via netty?
I'll soon be ready to give my soul for knowing how to transfer an image or file through netty.
I tried to write my own handler - I get crutches that still don’t work, I tried to wrap it in an object and pass it in - so the server simply doesn’t receive anything, I also tried using SimpleChannelInboundHandler (), but the situation is the same.
Please don't let me die, pamagiti
Answer the question
In order to leave comments, you need to log in
A rough sketch of the server-side handler:
public class FileServerHandler extends SimpleChannelInboundHandler<String> {
@Override
public void messageReceived(ChannelHandlerContext ctx, String fileName) throws Exception {
RandomAccessFile file = new RandomAccessFile(fileName, "r");
ctx.write(new DefaultFileRegion(file.getChannel(), 0, file.length()));
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question