Solved

Best Method for copying files across a domain?

Posted on 2008-10-16
12
285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 Comments
 
LVL 13

Expert Comment

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

Expert Comment

by:jinn_hnnl
ID: 22729367
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
ID: 22729374
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:janineo
ID: 22729414
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
ID: 22729541
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
ID: 22729587
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
 

Author Comment

by:janineo
ID: 22729748
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
ID: 22729967
"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
ID: 22730106
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
ID: 22730200
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
ID: 22730244
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
ID: 22730294
You are welcome,
^^
Glad to help

Jinn
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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