Solved

Best Method for copying files across a domain?

Posted on 2008-10-16
12
253 Views
Last Modified: 2013-12-17
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
Comment
Question by:janineo
  • 6
  • 5
12 Comments
 
LVL 13

Expert Comment

by:crazyman
Comment Utility
What sort of file sizes are we talking here...
0
 
LVL 10

Expert Comment

by:jinn_hnnl
Comment Utility
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
 

Author Comment

by:janineo
Comment Utility
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
 

Author Comment

by:janineo
Comment Utility
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
 
LVL 10

Expert Comment

by:jinn_hnnl
Comment Utility
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
 
LVL 10

Expert Comment

by:jinn_hnnl
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:janineo
Comment Utility
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
 
LVL 10

Expert Comment

by:jinn_hnnl
Comment Utility
"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
 

Author Comment

by:janineo
Comment Utility
Thanks for the examples.

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

Thanks,
Janine
0
 
LVL 10

Accepted Solution

by:
jinn_hnnl earned 500 total points
Comment Utility
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
 

Author Comment

by:janineo
Comment Utility
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
 
LVL 10

Expert Comment

by:jinn_hnnl
Comment Utility
You are welcome,
^^
Glad to help

Jinn
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now