Example #1
0
        public override UploadResult UploadText(string text, string fileName)
        {
            UploadResult ur = new UploadResult();

            if (!string.IsNullOrEmpty(text))
            {
                string domain;

                if (!string.IsNullOrEmpty(CustomDomain))
                {
                    domain = CustomDomain;
                }
                else
                {
                    domain = "http://hastebin.com";
                }

                ur.Response = SendRequest(HttpMethod.POST, URLHelpers.CombineURL(domain, "documents"), text);

                if (!string.IsNullOrEmpty(ur.Response))
                {
                    HastebinResponse response = JsonConvert.DeserializeObject <HastebinResponse>(ur.Response);

                    if (response != null && !string.IsNullOrEmpty(response.Key))
                    {
                        string url = URLHelpers.CombineURL(domain, response.Key);

                        string syntaxHighlighting = SyntaxHighlighting;

                        if (UseFileExtension)
                        {
                            string ext = Helpers.GetFilenameExtension(fileName);

                            if (!string.IsNullOrEmpty(ext) && !ext.Equals("txt", StringComparison.InvariantCultureIgnoreCase))
                            {
                                syntaxHighlighting = ext;
                            }
                        }

                        if (!string.IsNullOrEmpty(syntaxHighlighting))
                        {
                            url += "." + syntaxHighlighting;
                        }

                        ur.URL = url;
                    }
                }
            }

            return(ur);
        }
Example #2
0
        public override UploadResult UploadText(string text, string fileName)
        {
            UploadResult ur = new UploadResult();

            if (!string.IsNullOrEmpty(text))
            {
                string domain;

                if (!string.IsNullOrEmpty(CustomDomain))
                {
                    domain = CustomDomain;
                }
                else
                {
                    domain = "http://hastebin.com";
                }

                ur.Response = SendRequest(HttpMethod.POST, URLHelpers.CombineURL(domain, "documents"), text);

                if (!string.IsNullOrEmpty(ur.Response))
                {
                    HastebinResponse response = JsonConvert.DeserializeObject <HastebinResponse>(ur.Response);

                    if (response != null && !string.IsNullOrEmpty(response.Key))
                    {
                        string syntaxHighlighting;

                        if (!string.IsNullOrEmpty(SyntaxHighlighting))
                        {
                            syntaxHighlighting = SyntaxHighlighting;
                        }
                        else
                        {
                            syntaxHighlighting = "hs";
                        }

                        ur.URL = URLHelpers.CombineURL(domain, response.Key + "." + syntaxHighlighting);
                    }
                }
            }

            return(ur);
        }
Example #3
0
        public override UploadResult UploadText(string text, string fileName)
        {
            UploadResult ur = new UploadResult();

            if (!string.IsNullOrEmpty(text))
            {
                ur.Response = SendRequest(HttpMethod.POST, "http://hastebin.com/documents", text);

                if (!string.IsNullOrEmpty(ur.Response))
                {
                    HastebinResponse response = JsonConvert.DeserializeObject <HastebinResponse>(ur.Response);

                    if (response != null)
                    {
                        ur.URL = string.Format("http://hastebin.com/{0}.hs", response.Key);
                    }
                }
            }

            return(ur);
        }