use of com.generallycloud.baseio.container.FileSendUtil in project baseio by generallycloud.
the class TestDownloadServlet method doAccept.
@Override
protected void doAccept(SocketSession session, ParamedProtobaseFuture future) throws Exception {
FileSendUtil fileSendUtil = new FileSendUtil();
File file = new File(future.getParameters().getParameter(FileReceiveUtil.FILE_NAME));
if (!file.exists()) {
fileNotFound(session, future, "file not found");
return;
}
fileSendUtil.sendFile(session, future.getFutureName(), file, 1024 * 800);
}
use of com.generallycloud.baseio.container.FileSendUtil in project baseio by generallycloud.
the class TestUpload method main.
public static void main(String[] args) throws Exception {
String serviceName = "/test-upload";
IoEventHandleAdaptor eventHandle = new IoEventHandleAdaptor() {
@Override
public void accept(SocketSession session, Future future) throws Exception {
ProtobaseFuture f = (ProtobaseFuture) future;
System.out.println();
System.out.println(f.getReadText());
System.out.println();
CloseUtil.close(connector);
}
};
LoggerFactory.configure();
ServerConfiguration configuration = new ServerConfiguration(8300);
SocketChannelContext context = new NioSocketChannelContext(configuration);
connector = new SocketChannelConnector(context);
context.setIoEventHandleAdaptor(eventHandle);
context.setProtocolFactory(new ProtobaseProtocolFactory());
context.addSessionEventListener(new LoggerSocketSEListener());
SocketSession session = connector.connect();
String fileName = "lantern-installer-beta.exe";
fileName = "content.rar";
// fileName = "jdk-8u102-windows-x64.exe";
File file = new File("c:/ryms/" + fileName);
FileSendUtil fileSendUtil = new FileSendUtil();
fileSendUtil.sendFile(session, serviceName, file, 1024 * 800);
ThreadUtil.sleep(10000000);
}
Aggregations