From 751f11a213a71c322db201a24fada7543ca1f628 Mon Sep 17 00:00:00 2001 From: lithium_ Date: Mon, 30 May 2016 04:47:26 -0700 Subject: [PATCH 1/4] Lithiio Update Switched to JSON. --- ShareX.UploadersLib/Favicons/Lithiio.ico | Bin 1150 -> 318 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/ShareX.UploadersLib/Favicons/Lithiio.ico b/ShareX.UploadersLib/Favicons/Lithiio.ico index 51cae7cbcf5c3e3de2c84635fa97db8420163c3f..0a8e0d06e32de8c6d4537ca20259114f99bceaed 100644 GIT binary patch literal 318 zcmb7;u?>JQ3KGZb(D literal 1150 zcmbu5K?=h_37ChpLW=E)7_l;b_e!@q?3=0Fp?Q(i#_RL*QkL*sV{aKmKywYdqF8iDA?$3MfZ|Fw#`n6xuPo;nW From 4843b431ff1fccddf0af23b98ab8f9ed10729181 Mon Sep 17 00:00:00 2001 From: lithium_ Date: Mon, 30 May 2016 04:47:49 -0700 Subject: [PATCH 2/4] Revert "Lithiio Update" This reverts commit 751f11a213a71c322db201a24fada7543ca1f628. --- ShareX.UploadersLib/Favicons/Lithiio.ico | Bin 318 -> 1150 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/ShareX.UploadersLib/Favicons/Lithiio.ico b/ShareX.UploadersLib/Favicons/Lithiio.ico index 0a8e0d06e32de8c6d4537ca20259114f99bceaed..51cae7cbcf5c3e3de2c84635fa97db8420163c3f 100644 GIT binary patch literal 1150 zcmbu5K?=h_37ChpLW=E)7_l;b_e!@q?3=0Fp?Q(i#_RL*QkL*sV{aKmKywYdqF8iDA?$3MfZ|Fw#`n6xuPo;nW literal 318 zcmb7;u?>JQ3KGZb(D From 0029171fe081c025b504622436d98f460a748c7e Mon Sep 17 00:00:00 2001 From: lithium_ Date: Mon, 30 May 2016 04:48:58 -0700 Subject: [PATCH 3/4] Lithiio - Update Switched to JSON for neat error reporting capabilities. --- ShareX.UploadersLib/Favicons/Lithiio.ico | Bin 1150 -> 318 bytes ShareX.UploadersLib/FileUploaders/Lithiio.cs | 29 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ShareX.UploadersLib/Favicons/Lithiio.ico b/ShareX.UploadersLib/Favicons/Lithiio.ico index 51cae7cbcf5c3e3de2c84635fa97db8420163c3f..0a8e0d06e32de8c6d4537ca20259114f99bceaed 100644 GIT binary patch literal 318 zcmb7;u?>JQ3KGZb(D literal 1150 zcmbu5K?=h_37ChpLW=E)7_l;b_e!@q?3=0Fp?Q(i#_RL*QkL*sV{aKmKywYdqF8iDA?$3MfZ|Fw#`n6xuPo;nW diff --git a/ShareX.UploadersLib/FileUploaders/Lithiio.cs b/ShareX.UploadersLib/FileUploaders/Lithiio.cs index 0314f2486..2ceda9451 100644 --- a/ShareX.UploadersLib/FileUploaders/Lithiio.cs +++ b/ShareX.UploadersLib/FileUploaders/Lithiio.cs @@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License // Credits: https://github.com/lithium720 -using ShareX.HelpersLib; +using Newtonsoft.Json; using System.Collections.Generic; using System.IO; using System.Windows.Forms; @@ -58,7 +58,7 @@ public Lithiio(LithiioSettings config) Config = config; } - private const string uploadUrl = "http://api.lithi.io/upload.php"; + private const string uploadUrl = "http://api.lithi.io/v2/"; public static string[] UploadURLs = new string[] { "https://i.lithi.io/", "https://lithi.io/i/", "https://i.mugi.io/", "https://mugi.io/i/" }; @@ -66,31 +66,36 @@ public override UploadResult Upload(Stream stream, string fileName) { Dictionary arguments = new Dictionary(); arguments.Add("key", Config.UserAPIKey); + arguments.Add("linktype", Config.UploadURL); UploadResult result = UploadData(stream, uploadUrl, fileName, "file", arguments, method: HttpMethod.POST); + LithiioResponse Response = JsonConvert.DeserializeObject(result.Response); if (result.Response == null) { - Errors.Add("Upload failed for unknown reason. Check your API key."); + Errors.Add("Upload failed for unknown reason."); return result; } if (result.IsSuccess) { - result.URL = URLHelpers.CombineURL(Config.UploadURL, result.Response); + if (Response.Success) + { + result.URL = Response.URL; + } + else + { + Errors.Add(Response.Error); + } } return result; } - internal class LithiioResponse + public class LithiioResponse { - public string url { get; set; } - public List errors { get; set; } - } - - internal class LithiioFile - { - public string url { get; set; } + public bool Success { get; set; } + public string URL { get; set; } + public string Error { get; set; } } } From 7e32d0120daa4f71ca49f284d6c40034d1774b5f Mon Sep 17 00:00:00 2001 From: lithium_ Date: Mon, 30 May 2016 05:59:04 -0700 Subject: [PATCH 4/4] Lithiio - More update Made suggested revisions --- ShareX.UploadersLib/FileUploaders/Lithiio.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/ShareX.UploadersLib/FileUploaders/Lithiio.cs b/ShareX.UploadersLib/FileUploaders/Lithiio.cs index 2ceda9451..761a0f34f 100644 --- a/ShareX.UploadersLib/FileUploaders/Lithiio.cs +++ b/ShareX.UploadersLib/FileUploaders/Lithiio.cs @@ -67,24 +67,18 @@ public override UploadResult Upload(Stream stream, string fileName) Dictionary arguments = new Dictionary(); arguments.Add("key", Config.UserAPIKey); arguments.Add("linktype", Config.UploadURL); - UploadResult result = UploadData(stream, uploadUrl, fileName, "file", arguments, method: HttpMethod.POST); - LithiioResponse Response = JsonConvert.DeserializeObject(result.Response); - - if (result.Response == null) - { - Errors.Add("Upload failed for unknown reason."); - return result; - } + UploadResult result = UploadData(stream, uploadUrl, fileName, "file", arguments); if (result.IsSuccess) { - if (Response.Success) + LithiioResponse response = JsonConvert.DeserializeObject(result.Response); + if (response.Success) { - result.URL = Response.URL; + result.URL = response.URL; } else { - Errors.Add(Response.Error); + Errors.Add(response.Error); } }