Added Hastebin text uploader

This commit is contained in:
Jaex 2014-09-24 03:01:04 +03:00
parent e3bdefe37c
commit 3f4ebc3d33
4 changed files with 65 additions and 0 deletions

View file

@ -776,6 +776,9 @@ public UploadResult UploadText(Stream stream, string fileName)
IsPublic = Program.UploadersConfig.UpasteIsPublic
};
break;
case TextDestination.Hastebin:
textUploader = new Hastebin();
break;
case TextDestination.CustomTextUploader:
if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomTextUploaderSelected))
{

View file

@ -69,6 +69,8 @@ public enum TextDestination
Gist,
[Description("uPaste")]
Upaste,
[Description("Hastebin")]
Hastebin,
[Description("Custom text uploader")]
CustomTextUploader,
[Description("File uploader")]

View file

@ -0,0 +1,59 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright (C) 2007-2014 ShareX Developers
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/
#endregion License Information (GPL v3)
using Newtonsoft.Json;
namespace UploadersLib.TextUploaders
{
public sealed class Hastebin : TextUploader
{
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;
}
private class HastebinResponse
{
public string Key { get; set; }
}
}
}

View file

@ -183,6 +183,7 @@
<Compile Include="FileUploaders\GfycatUploader.cs" />
<Compile Include="HelperClasses\OAuth\IOAuthBase.cs" />
<Compile Include="ImageUploaders\Chevereto.cs" />
<Compile Include="TextUploaders\Hastebin.cs" />
<Compile Include="TextUploaders\Upaste.cs" />
<Compile Include="UploadersConfig.cs" />
<Compile Include="Forms\UserPassBox.cs">