[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

Best Method for copying files across a domain?

I'm building an ASP.NET external facing web site, which will be under SSL.
We are going to allow our users to upload files to our server via this site.

I need a method of transferring those files from the web server to our internal application server. They will be on the same domain, and possibly even physically in the same room.

What is the quickest and safest method of transferring these files from the web server to the application server, as they are uploaded - e.g not in an over night batch.

I have considered FTP and the System.IO classes. I think FTP is faster, but I'm not sure, especially via the FTPRequest class. The System.IO classes seem simpler to implement.

Can anyone offer advantages & disadvatages of each, or any other methods not mentioned?

Many Thanks,
Janine
0
janineo
Asked:
janineo
  • 6
  • 5
1 Solution
 
crazymanCommented:
What sort of file sizes are we talking here...
0
 
jinn_hnnlCommented:
I am not sure how you want to use FTPRequest for your scenario???

Because as I understand user file has been uploaded sucessfully and you want to copy them across to another application (which have different location). This is unnecessarily using FTP thing

The FTPRequest is faster and work better if you have a FTP server configured for downloading and uploading. But requires to configure a lot, if that webserver is behind proxy server I think you will have another problem. FTP will be helpful if you want to download and upload something especially to FTP server. And with FTPStatusCode you can see how far the process go... (you can do the same for IO)

But do you want to execute this as soon as the user finish upload or do it some where in admin page? Either case, set up some functions and call them.

If my guess is right, In your case, you better just use normal System.IO. If it is in the same host computer. IO will be perfect

Hope this helps




public string CopyNewFileToInternalServer(string newfile,string userUploadFile)
    {
        try
        {
          
            string path = Server.MapPath("D:/InternalApplication/FromUserUpload" + newfile); <-- new internal application file
            File.Copy(Server.MapPath("~/UserUpload/" + userUploadFile), path, true); //<--- this is the original file
            return path;
        }
        catch (IOException ex)
        {
            
            return "";
        }
    }

Open in new window

0
 
janineoAuthor Commented:
I don't think there are going to be huge - probably images from a digital compact camera, word docs, perhaps some scanned tiff files, or pdfs.

I think 2Mb would be a large file, and most would be less than 1Mb.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
janineoAuthor Commented:
The reason I'm considering FTP is that the destination is already set up as an FTP server as that's what we use to transfer files to it from our satellite file servers. (Each office has it's own server which transfers files to the main server).

But the application that sends the files is written in VB6, so there was no access to the System.IO classes for that.

The new web server is written in .NET, so we now have the option to use System.IO.

We want to execute the transfer as soon as the file has finished uploading. The web server will probably be behind a proxy.
The host servers will be different, but quite possibly in the same rack.
0
 
jinn_hnnlCommented:
Well,

You said "possibly even physically in the same room", then I guess, the new web server is located on the main server (which from before: files are transfered to from satellite servers).
And this same main server has the application server running and processing these files.
If so I think you really better use System.IO, it simplify a lot of your job.

I have used them several time and 2Mb is not a problem for your performance

Then you said: "The host servers will be different", it means the webserver and the application server are in different machine physically (I am not talking about domain). Then IO won't work. This case, FTP will be a very good option beside standard ASP.NET FileUpload control.

Then you will face quiet a lot of FTPREquest issues with Proxy but it solvable.

Hope this helps
JINN

0
 
jinn_hnnlCommented:
So depend on your company request, I am sure it's changeable (howyour boss wants it) the 2 method can be useful. Either case, FTP seems to be more generic, fater, more option (not only copying file) which might be useful for future development. But it requires more configuration and research.

This link can be helpful if you want to go further with FTP:
http://www.codeproject.com/KB/dotnet/dotnetftp.aspx

FTP client library
http://www.csharphelp.com/archives/archive9.html
0
 
janineoAuthor Commented:
They will be in physically different boxes, with different IP addresses, but on the same domain.

When I said web server, I meant the physical server box the web site is installed on, sorry for the confusion.
We have a server room in our main office which contains all the main server boxes in racks. There is a gigabit connection between them.

The application server is a physically different box to the web server. (The application server runs the file store and the application which serves about 800 seats. There is no processing power left for the web too).

Is it not possible to use IO to transfer files across the domain? I can certainly do it with Windows Explorer, so why not with IO?

As for company requests - if I provide a compelling argument for either method, then they will go with it.

Thanks,
Janine
0
 
jinn_hnnlCommented:
"Is it not possible to use IO to transfer files across the domain? I can certainly do it with Windows Explorer, so why not with IO?"

Ohh, then they are network driver. Well in that case you can perfectly use System.IO
I guess that application server where store file will have the map like Y:\UserFiles\

or share map (run from window run) like: \\MachineName\UserFiles

If this will always be the case, then you can use IO with a bit more configuration (permission so Webserver can connect and write file to that Application Server, and take care of impersonate in the web.config.
You can use System.IO namespace and UNC share path (such as \\RemoteMachineName\SharedFolder) to access the file exists in the remote server. If you do so, you also need to set proper permissions for your application on this UNC path.

File.Copy(D:\\UserUpload\data.txt, \\MachineName\UserFiles\\data.txt, true);

There will be security issues come after but this is doable.

JINN

PS: Try this:

using System;
using System.IO;
 
public class....
.....
public void TestNetworkDrives() 
    {
 
        // Make a reference to a directory.
        DirectoryInfo di = new DirectoryInfo("Y:\\");
 
        // Get a reference to each directory in that directory.
        DirectoryInfo[] diArr = di.GetDirectories();
 
        // Display the names of the directories.
        foreach (DirectoryInfo dri in diArr)
            Response.Write(dri.Name + " <br />");
    }

Open in new window

0
 
janineoAuthor Commented:
Thanks for the examples.

As both methods are possible, which would you recommend for speed & security?

Thanks,
Janine
0
 
jinn_hnnlCommented:
Well...

As I said, depend on your company current situation and development plan. If you think it's gonna stay this way for the next 4 5 year (within a share network and mapping drives) then I would recommend using System.IO, this requires pure System resource instead of depending on FTP connection. And as it's the back-office processes. Security is only the part that you make your webserver and fileserver understand each other.

The FTP is for more advance purpose, but Dot Net doesn't support them much even since 2.0.

So go for IO I would say!

For more information about FTP (incase you want to refer to) look at this example:
http://www.codeguru.com/csharp/.net/net_security/authentication/article.php/c15051

security configured, I tried, quite buggy but a good example

JINN


0
 
janineoAuthor Commented:
Okay, thanks for your thoughts, and the links and code examples.

I'll discuss with manager and we'll make a decision then.

Thanks,
Janine
0
 
jinn_hnnlCommented:
You are welcome,
^^
Glad to help

Jinn
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now