*
The moose likes Distributed Java and the fly likes Upload File, Save to different server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Upload File, Save to different server" Watch "Upload File, Save to different server" New topic
Author

Upload File, Save to different server

Christopher McCauley
Greenhorn

Joined: Jan 03, 2005
Posts: 27
Upload and write to local server I got...now I need to move that file to another server, at the same time and be able to allow then to access the file.

It has been suggested to me that I 'consume an EJB' that will enable me to save a file to a different server than the one the site is running on. Because we do not use EJB (this is a Struts based app) I am inclined to look elsewhere foa solution. Can't I simply FTP the file to the alternate server?

Any guidance or solution or idea is welcome...

TIA,
Christopher



JCM<br />good at cookin'
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

I understand the "I need to move that file to another server" part of your question, but I'm not clear on the "at the same time and be able to allow then to access the file".

I don't think using EJBs is really required for the solution - it could be *a* solution, but I think it's a bit of overkill to just back up files to a different server. Plus, it sounds like you're not all that familiar with EJBs, and getting up to speed could take a while.

What specific file transfer mechanism to use is the least of your worries - you can use pretty much any applicable technology that the second server supports - FTP, HTTP, EJBs, web services, writing to a mapped network drive, etc. - however, what you really need to look at is how this affects the flow and performance of your web application.

When a user uploads a file, does the file get sent to the second server during the user's request? Or does it get sent to the second server later by some other means? Depending on network speed and other things, sending the file to the second server during the user's request could make the request take a lot longer. Though if you go with the "file gets sent later" approach, you'll have to look at both the local and remote servers for the file - you won't know if the file has been sent to the second server yet. Also, you'll have to figure out how this "send files to the second server" part works - do you want to write your own separate program that does this? In Java, or just a cron script? Or do you want to run something like Quartz scheduler inside your web app?

How are you going to deal with information about the files? Are you going to go to the remote server every time to get this? Again, this could slow down your web app a lot. You could keep track of this file information in JavaBeans in your web app, but again, this means that you have to capture the information you need to display (file name, size, maybe how to download real file, etc.) when the file is uploaded, and have some way to save or rebuild this information between server re-starts.

Why can't you save files locally, again?


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Upload File, Save to different server
 
Similar Threads
Retrieving file at server side
Uploading a file
delete zip file
Upload file from Client Browser
To upload a file using struts 1.2 and ajax