示例#1
0
        ///<summary>
        ///Copy file from HDFS to local machine
        ///<param name="sourcePath">Location of file on HDFS, including filename and extension (FullFileName)</param>
        ///<param name="targetPath">Location of file to localhost,including filename and extension (FullFileName) </param>
        ///<returns>HttpStatusCode</returns>
        ///</summary>
        public HttpStatusCode copyToLocal(string sourcePath, string targetPath)
        {
            // Create the final url with params
            string          urlPath = "http://" + this.namenodeHost + ":" + this.namenodePort + WEBHDFS_CONTEXT_ROOT + "/" + sourcePath + "?op=OPEN&overwrite=true&user.name=" + this.hdfsUsername;
            BetterWebClient wc      = new BetterWebClient();

            wc.AllowAutoRedirect = true;
            wc.DownloadFile(urlPath, targetPath);
            return(wc.StatusCode());
        }
示例#2
0
        public void GetMasterZip()
        {
            BetterWebClient downloadClient = new BetterWebClient();

            if (!Directory.Exists(Skin.Skin.DownloadFolderName))
            {
                Directory.CreateDirectory(Skin.Skin.DownloadFolderName);
            }
            if (!File.Exists(Path.Combine(Skin.Skin.DownloadFolderName, _filename)) || _overwrite)
            {
                downloadClient.DownloadFile(GithubBaseURL + _user + "/" + _repo + "/archive/master.zip",
                                            Path.Combine(Skin.Skin.DownloadFolderName, _filename));
            }
        }
示例#3
0
        public void GetLatestReleaseZip()
        {
            BetterWebClient downloadClient = new BetterWebClient();

            if (!Directory.Exists(Skin.Skin.DownloadFolderName))
            {
                Directory.CreateDirectory(Skin.Skin.DownloadFolderName);
            }
            if (string.IsNullOrEmpty(_latestTag))
            {
                GetLatestReleaseTag();
            }
            if (!File.Exists(Path.Combine(Skin.Skin.DownloadFolderName, _filename)) || _overwrite)
            {
                downloadClient.DownloadFile(GithubAPIRepoBaseURL + _user + "/" + _repo + "/zipball/" + _latestTag,
                                            Path.Combine(Skin.Skin.DownloadFolderName, _filename));
            }
        }
示例#4
0
        public void GetFile()
        {
            if (!Directory.Exists(Skin.Skin.DownloadFolderName))
            {
                Directory.CreateDirectory(Skin.Skin.DownloadFolderName);
            }
            if (string.IsNullOrEmpty(_deviantPageString))
            {
                if (!FetchDeviantArtPage())
                {
                    throw new Exception("Couldn't fetch the DeviantArt page of this item.");
                }
            }
            if (File.Exists(Path.Combine(Skin.Skin.DownloadFolderName, _filename)) && !_overwrite)
            {
                return;
            }
            Regex           downloadLinkRegex = new Regex(@"""(http://www\.deviantart\.com/download/\d*/.*)""");
            string          downloadUrl       = downloadLinkRegex.Match(_deviantPageString).Groups[1].Value.Replace("&amp;", "&");
            BetterWebClient downloadClient    = new BetterWebClient(_cookieContainer, _url);

            downloadClient.DownloadFile(downloadUrl, Path.Combine(Skin.Skin.DownloadFolderName, _filename));
        }