1

Was wondering the best way to do the following:

I am uploading a file to my server, but do not want to keep it on my server. The file is a video file and uploaded by users who want to post their video on the site for their friends to watch.

I am using NeatUpload as my upload control as I am not really allowed to use flash, although if the argument for using flash is greater than the one for not using it then I could persuade the people in charge that this is a viable option.

So once the file is in a stream on my server I then upload it via ftp to the streaming servers where it will be played from.

How can I get this to ftp without holding up the user? I already held them up getting it to my server, I do not really want to double the waiting the time.

I have already written code that does the upload and ftp, I am just looking for the right way to do the ftp without holding up the user.

bgmCoder
  • 6,205
  • 8
  • 58
  • 105
jimplode
  • 3,474
  • 3
  • 24
  • 42

2 Answers2

0

Personally, I am using a combination of ASP.NET, a database/file system folder and a console application running as a Scheduled Task.

When a user uploads, I put the file in a special "pick-up" folder, optionally generate a database entry (if required to pass more information than just the file).

Then the ASP.NET part is done.

A console application running as a Scheduled Task (e.g. ever 5 minutes) iterates all DB and/or file system entries, processing each one by uploading it to your other server via FTP and removing the file and DB entry after it is being processed.

(Probably this solution is criticizable as a "poor-man's solution" in term of technology (e.g. by not using Windows services), in my projects this always worked pretty well, though.)

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • 1
    This is a solution I had considered, but using a service, but was hoping that I could just thread this off like I would in a WPF app. – jimplode Jun 21 '11 at 10:57
  • @jimplode Since I never fully understood threading in ASP.NET, I never relied on such a solution, also I am sure this should be very well possible. – Uwe Keim Jun 21 '11 at 11:00
0

This is how you can do the threaded bit:

Stream stream = new MemoryStream();                
inputFileId.FileContent.CopyTo(stream);

ThreadPool.QueueUserWorkItem(delegate { SendViaFTP(inputFileId.FileName, stream); });
jimplode
  • 3,474
  • 3
  • 24
  • 42