Пример #1
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password))
            {
                Errors.Add("RapidShare account username or password is empty.");
                return(null);
            }

            string url = NextUploadServer();

            if (string.IsNullOrEmpty(url))
            {
                Errors.Add("RapidShare next upload server URL is empty.");
                return(null);
            }

            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("sub", "upload");
            args.Add("login", Username);
            args.Add("password", Password);

            if (!string.IsNullOrEmpty(FolderID))
            {
                args.Add("folder", FolderID);
            }

            UploadResult result = UploadData(stream, url, fileName, "filecontent", args);

            if (result.IsSuccess)
            {
                if (result.Response.StartsWith("ERROR: "))
                {
                    Errors.Add(result.Response.Substring(7));
                }
                else if (result.Response.StartsWith("COMPLETE\n"))
                {
                    RapidShareUploadInfo info = new RapidShareUploadInfo(result.Response);
                    result.URL = info.URL;
                }
            }

            return(result);
        }
Пример #2
0
        public override UploadResult Upload(Stream stream, string fileName)
        {
            if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password))
            {
                Errors.Add("RapidShare account username or password is empty.");
                return null;
            }

            string url = NextUploadServer();

            if (string.IsNullOrEmpty(url))
            {
                Errors.Add("RapidShare next upload server URL is empty.");
                return null;
            }

            Dictionary<string, string> args = new Dictionary<string, string>();
            args.Add("sub", "upload");
            args.Add("login", Username);
            args.Add("password", Password);

            if (!string.IsNullOrEmpty(FolderID))
            {
                args.Add("folder", FolderID);
            }

            UploadResult result = UploadData(stream, url, fileName, "filecontent", args);

            if (result.IsSuccess)
            {
                if (result.Response.StartsWith("ERROR: "))
                {
                    Errors.Add(result.Response.Substring(7));
                }
                else if (result.Response.StartsWith("COMPLETE\n"))
                {
                    RapidShareUploadInfo info = new RapidShareUploadInfo(result.Response);
                    result.URL = info.URL;
                }
            }

            return result;
        }