I have a functioning RMI application, and I have decided that I want the client to be able to send a 1GB file to the server. Obviously, as this is RMI, I can't just pass in a FileInputStream to my remote method call. Also, I can't read the whole file in to a bytearray and send that over, since the file is too big to fit in memory.
What's the best way (or any way) to do this, then? I assume that there's some standard way to do this, but I haven't been able to figure it out.
As you've found - RMI isn't a great way to send files full of data - so why do you want to only use RMI to do this? One good approach is to have the server respond to the client with *where* it can get the file (as a URL), and then have the client use FTP or some other protocol to download the file.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: Feb 16, 2004
The client is sending the file to the server, not vice-versa....
My client app runs on a user's desktop and performs all operations against the server via RMI. The client has no HTTP or FTP server running, and user requirements specify that this will not change. Can I open a socket or something? There's got to be a way to do this - I can't be the only person who's wanted to send a file from a client to a server..... [ August 15, 2005: Message edited by: Tom McAmmond ]
Oops... sorry, didn't notice that the file was coming from the client until you pointed it out...
Hmmm... not sure if there's a "standard" or "common" way of going about this...
You wouldn't necessarily need a FTP server running on the client to use FTP - you could have an FTP server running on the server and use the FTP protocol to send the files from the client.
This would probably require you to dig a bit into FTP protocol internals.
You could also definitely use straight sockets to do this, too - something like -
1.) Have the client call a server RMI method that returns an IP and port to send the file to. 2.) The server start up a ServerSocket and return it's IP and port to the client. 3.) The client then opens a socket using the data supplied, opens an output stream to the file (hopefully wrapped in a buffered stream, and maybe even using a gzipped stream to speed things up) and stream the file data across the socket.
Hopefully this helps you figure a good approach out...