
",,,using sockets and copy paste the file, but this is a very slow process.,," If u want to view the file on the client side then it will be streamed (downloaded) one way or another. The exception is when you are remotely viewing the desktop of the server. Usually big files are streamed i.e. sections of the file are downloaded for view. For example if you are looking at page 1 then the next two pages can be downloaded in advance but not the entire document. Your problem with these files is that you have to read them through the application that reads those files, and the application should provide you with an API for streaming data into the application. This is what happens with multi-media streaming software. The File Format of the file should also be optimised for streaming. Multi-media files are optimized because it's widely known that they can be streamed. Streaming has to be done properly (and in part I will explain to you why the File Format has to be optimized for this-as I mentioned above): Imagine a video file being streamed. Packets of data don't follow the same path to the client. So the client application cannot assume that the packets it receives are in the same order as they were sent by the server. Video files (the file format) have extra data, usually a video frame number, and each frame is packaged into a packet. When a client gets the packet, thus the frame, it will order it in the correct order before playing the video. There is more to this but I believe you get the picture. Similarly apply this to files like pdfs. If the file is streamed then there needs to be some data in the File Format to tell the client how to arrange the packets it receives. I doubt pdfs have such a mechanism because when u view a pdf on a webpage, the file is first wholy downloaded. The above details are at the low level and there could be some tool to help you but probably not to the extent you expect. I'm only telling you the above so that you see the devil is in the details! Note: Streaming the file is not about RMI, but more about network programming. Also keep in mind, if we are talking about .doc files, which can be modified then it gets trickier. If the client makes a change on the file then those changes have to be saved on the original document on the server, and that means operating on sections of the file at the binary level, and also handling conflicts at that level if more that one user is working on the file. O_O --- On Thu, 4/16/09, Duggan Kim <mdkimani@gmail.com> wrote: From: Duggan Kim <mdkimani@gmail.com> Subject: Re: [Skunkworks] Java RMI / Network Programming To: "Skunkworks forum" <skunkworks@lists.my.co.ke> Date: Thursday, April 16, 2009, 4:41 PM Hi Guys, Thank you for the responses. I would just like to shed a little more light on the problem. I am currently able to get a reference to the file from my server, but even through this reference, the details in the file object are only usable within the server, e.g the path has the value like C:\docs\hello.pdf. This path is not usable within the client. I can create an input stream and output stream between the client and server using sockets and copy paste the file, but this is a very slow process. The server and client communicate via RMI, but to open a file, I am using: Process p = Runtime.getRuntime().exec("cmd /c start '+ path); the path provided by the server cannot be used by the client to open the right file. How else can this be done? Thank you, Duggan Kim On 4/16/09, wesley kiriinya <kiriinya2000@yahoo.com> wrote:
The devil is in the details for these sort of problem:
It is a complex problem because:
1. Files like pdf, doc, ... are files containing information that only the application that uses that file understands. Let's call it File Format. Unless the File Format is open (so that you know how to read the file data) then you will have to read the file through it's application. If the application (e.g. M$ Word) does not provide an API to stream a .doc file contents to the application then your other option is to open the network connection, stream the entire file and create a copy of it in the local system, then open that local file.
1.1. If for example you would like changes to the .doc file to be saved in the server, then you need to program the locking, unlocking stuff in the application that opens the file (in this case M$ Word) and the application needs to provide you with those mechanisms. If you did the local file way (as described above) then you have to take care of a problem where saving the file changes might result in a conflict. You can intergrate your network communication tool with a tool like SVN, so that SVN can pull the file for you and it will help you manage file conflict resolution.
2. If the file is not on a shared folder then you need a program running on the server to listen to client requests. With what you are planning to do, you might open a security hole through this server application.
o_O
--- On Wed, 4/15/09, Duggan Kim <mdkimani@gmail.com> wrote:
From: Duggan Kim <mdkimani@gmail.com> Subject: [Skunkworks] Java RMI / Network Programming To: skunkworks@lists.my.co.ke Date: Wednesday, April 15, 2009, 5:49 PM
I am writing a java based peer to peer application that requires remote files (pdf, text, .doc etc) in the server to be opened(run) in the client, the same way you would open a shared file in a different machine from your machine. How do I create a URL to the remote file considering that the file is not necessary contained in a shared folder, or how do you open the file via a remote File object reference?
Any ideas would be appreciated.
Thank you,
Duggan Kimani. _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke
_______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Skunkworks announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science - http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi - http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general