Search code examples
c#asp.netftpfilestreamneatupload

FTP file upload without holding up user journey more than the initial upload


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.


Solution

  • This is how you can do the threaded bit:

    Stream stream = new MemoryStream();                
    inputFileId.FileContent.CopyTo(stream);
    
    ThreadPool.QueueUserWorkItem(delegate { SendViaFTP(inputFileId.FileName, stream); });