Пример #1
0
        public static WebUploader GetWebUploader(TransferParameter parameter)
        {
            try
            {
                WebUploader uploader = null;
                Log.Debug("WebUploader  create: url=" + parameter.TransferUrl + ",remoteFile=" + parameter.RemoteFile + ",localFile=" + parameter.LocalFile + ",chunkCount=" + parameter.ChunkSize.ToString());
                var uri = new Uri(parameter.TransferUrl);
                Log.Debug("WebUploader uri.Scheme=" + uri.Scheme);
                switch (uri.Scheme)
                {
                case "http":
                    uploader = new HttpWebUploader(parameter);
                    break;

                case "ftp":
                    uploader = new FtpWebUploader(parameter);
                    break;
                }
                return(uploader);
            }
            catch (ArgumentNullException e)
            {
                Log.Warn(e);
                return(null);
            }
            catch (UriFormatException e)
            {
                Log.Warn(e);
                return(null);
            }
        }
Пример #2
0
        public static WebDownloader GetDownloader(TransferParameter parameter)
        {
            var uri = new Uri(parameter.TransferUrl);

            switch (uri.Scheme)
            {
            case "http":
                if (parameter.SupportBrokenResume)
                {
                    return(new BlockDownloader(parameter));
                }
                return(new HttpDownloader(parameter));

            case "ftp":
                return(new FtpDownloader(parameter));

            default:
                return(null);
            }
        }