mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Added upaste.me text uploader
This commit is contained in:
parent
dacc13b96a
commit
2bf1284601
6 changed files with 107 additions and 0 deletions
|
@ -672,6 +672,9 @@ public UploadResult UploadText(Stream stream, string fileName)
|
|||
? new Gist(Program.UploadersConfig.GistPublishPublic)
|
||||
: new Gist(Program.UploadersConfig.GistPublishPublic, Program.UploadersConfig.GistOAuth2Info);
|
||||
break;
|
||||
case TextDestination.Upaste:
|
||||
textUploader = new Upaste(ApiKeys.UpasteKey);
|
||||
break;
|
||||
case TextDestination.CustomTextUploader:
|
||||
if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomTextUploaderSelected))
|
||||
{
|
||||
|
|
|
@ -64,6 +64,7 @@ public static class ApiKeys
|
|||
public const string PastebinCaKey = "KxTofLKQThSBZ63Gpa7hYLlMdyQlMD6u";
|
||||
public const string GistId = "badfa7b5e0a67e31da88";
|
||||
public const string GistSecret = "a538eff39300680f43d123a59ab9c1d9d4763640";
|
||||
public const string UpasteKey = "67941cA40Ca76625c6Fa96e59b98be9f";
|
||||
|
||||
// URL Shorteners
|
||||
public const string BitlyClientID = "0bf9726bea922ab7d5760a913d6749b441e5176a";
|
||||
|
|
|
@ -124,6 +124,9 @@ public class UploadersAPIKeys
|
|||
[Category("Pastebin"), DefaultValue(ApiKeys.PastebinCaKey), Description("Pastebin Consumer Secret")]
|
||||
public string PastebinCaKey { get; set; }
|
||||
|
||||
[Category("Upaste"), DefaultValue(ApiKeys.UpasteKey), Description("Upaste Key")]
|
||||
public string UpasteKey { get; set; }
|
||||
|
||||
#endregion Text Uploaders
|
||||
|
||||
#region URL Shorteners
|
||||
|
|
|
@ -77,6 +77,8 @@ public enum TextDestination
|
|||
Paste_ee,
|
||||
[Description("gist.github.com")]
|
||||
Gist,
|
||||
[Description("upaste.me")]
|
||||
Upaste,
|
||||
[Description("Custom text uploader")]
|
||||
CustomTextUploader,
|
||||
[Description("File uploader")]
|
||||
|
|
97
UploadersLib/TextUploaders/Upaste.cs
Normal file
97
UploadersLib/TextUploaders/Upaste.cs
Normal file
|
@ -0,0 +1,97 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (C) 2008-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;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UploadersLib.TextUploaders
|
||||
{
|
||||
public sealed class Upaste : TextUploader
|
||||
{
|
||||
private const string APIURL = "http://upaste.me/api";
|
||||
|
||||
public string APIKey { get; private set; }
|
||||
|
||||
public Upaste(string apiKey)
|
||||
{
|
||||
APIKey = apiKey;
|
||||
}
|
||||
|
||||
public override UploadResult UploadText(string text, string fileName)
|
||||
{
|
||||
UploadResult ur = new UploadResult();
|
||||
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
Dictionary<string, string> arguments = new Dictionary<string, string>();
|
||||
arguments.Add("api_key", APIKey);
|
||||
arguments.Add("paste", text);
|
||||
//arguments.Add("syntax", "");
|
||||
//arguments.Add("name", "");
|
||||
arguments.Add("privacy", "1"); // 0 public 1 private
|
||||
arguments.Add("expire", "n");
|
||||
arguments.Add("json", "true");
|
||||
|
||||
ur.Response = SendPostRequest(APIURL, arguments);
|
||||
|
||||
if (!string.IsNullOrEmpty(ur.Response))
|
||||
{
|
||||
UpasteResponse response = JsonConvert.DeserializeObject<UpasteResponse>(ur.Response);
|
||||
|
||||
if (response != null)
|
||||
{
|
||||
if (response.status.Equals("success", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
ur.URL = response.paste.link;
|
||||
}
|
||||
else
|
||||
{
|
||||
Errors.Add(response.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ur;
|
||||
}
|
||||
|
||||
public class UpastePaste
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string link { get; set; }
|
||||
public string raw { get; set; }
|
||||
public string download { get; set; }
|
||||
}
|
||||
|
||||
public class UpasteResponse
|
||||
{
|
||||
public UpastePaste paste { get; set; }
|
||||
public int errorcode { get; set; }
|
||||
public string error { get; set; }
|
||||
public string status { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -189,6 +189,7 @@
|
|||
<Compile Include="GUI\UploadersConfigForm.Designer.cs">
|
||||
<DependentUpon>UploadersConfigForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="TextUploaders\Upaste.cs" />
|
||||
<Compile Include="UploadersConfig.cs" />
|
||||
<Compile Include="GUI\UserPassBox.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
|
Loading…
Reference in a new issue