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);
            }

            string response = UploadData(stream, url, fileName, "filecontent", args);

            UploadResult result = new UploadResult(response);

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

            return(result);
        }
Exemple #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;
        }