mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Lithiio - Update
Switched to JSON for neat error reporting capabilities.
This commit is contained in:
parent
4843b431ff
commit
0029171fe0
2 changed files with 17 additions and 12 deletions
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 318 B |
|
@ -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<string, string> arguments = new Dictionary<string, string>();
|
||||
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<LithiioResponse>(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<string> 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; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue