Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Do a Server To Server File Transfer without any user interaction?

In my scenario, users are able to upload zip files to a.example.com

I would love to create a "daemon" which in specified time intervals will move-transfer any zip files uploaded by the users from a.example.com to b.example.com

From the info i gathered so far,

  1. The daemon will be an .ashx generic handler.
  2. The daemon will be triggered at the specified time intervals via a plesk cron job
  3. The daemon (thanks to SLaks) will consist of two FtpWebRequest's (One for reading and one for writing).

So the question is how could i implement step 3?

  • Do i have to read into to a memory() array the whole file and try to write that in b.example.com ?
  • How could i write the info i read to b.example.com?
  • Could i perform reading and writing of the file at the same time?

No i am not asking for the full code, i just can figure out, how could i perform reading and writing on the fly, without user interaction.

I mean i could download the file locally from a.example.com and upload it at b.example.com but that is not the point.

like image 332
OrElse Avatar asked Feb 16 '11 18:02

OrElse


People also ask

How do I transfer files from server to server?

To transfer files between 2 Windows servers, the traditional way is to use FTP desktop app as a middle-man. You need to download Filezilla or other FTP desktop tool, configure and use it to upload or download files between two remote servers.

How do I transfer files between two Windows servers?

Therefore, you can use an FTP connection to share files among two Windows Servers. Also, the SCP command is another way to transfer the files among two Windows Servers. But, the best method for file transfer is by using file transfer software that is EaseUS Todo PCTrans Technician File Transfer Software.


1 Answers

Here is another solution:

  1. Let ASP.Net in server A receive the file as a regular file upload and store it in directory XXX
  2. Have a windows service in server A that checks directory XXX for new files.
  3. Let the window service upload the file to server B using HttpWebRequest
  4. Let server B receive the file using a regular ASP.Net file upload page.

Links:

  • File upload example (ASP.Net): http://msdn.microsoft.com/en-us/library/aa479405.aspx
  • Building a windows service: http://www.codeproject.com/KB/system/WindowsService.aspx
  • Uploading files using HttpWebRequest: Upload files with HTTPWebrequest (multipart/form-data)

Problems you gotto solve:

  1. How to determine which files to upload to server B. I would use Directory.GetFiles in a Timer to find new files instead of using a FileSystemWatcher. You need to be able to check if a file have been uploaded previously (delete it, rename it, check DB or whatever suits your needs).

  2. Authentication on server B, so that only you can upload files to it.

like image 73
jgauffin Avatar answered Oct 10 '22 12:10

jgauffin