Hi,
I was trying to use MINA to transfer files between machines. It was pretty
good when I was trying to send some small files, but when the requests were
larger, (a file > 100M),  I could not send the file correctly. Since I could
not send the file in just one ByteBuffer, I read some of the file and send,
then read the rest of the file and send. But, the file received is not equal
to the file sent by the server. The file length is correct, but the contents
were interleaved. 

The following is the code to send file in server side:
        private void sendFile(IoSession session, String fileName) throws
FileNotFoundException {
                byte[] buffer = new byte[1024];
                DataInputStream dis = new DataInputStream(new 
FileInputStream(fileName));
                int bytesRead = 0;
                try {
                        System.out.println("send file");
                        while ((bytesRead = dis.read(buffer, 0, 1024)) > 0) {
                                session.write(ByteBuffer.wrap(buffer, 0, 
bytesRead));
                        }
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }
Some questions:
Is there any misuse of session and request in the code above?
Is there any good suggestions to do file or large request transfer in MINA?

-- 
View this message in context: 
http://www.nabble.com/Question-for-transfering-large-file-tf4222408s16868.html#a12011448
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.

Reply via email to