Merge pull request #1591 from lithium720/master

Lithiio - Update
This commit is contained in:
Jaex 2016-05-30 17:32:58 +03:00
commit 45950cd99d
2 changed files with 17 additions and 18 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 318 B

View file

@ -25,7 +25,7 @@
// 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,30 @@ public override UploadResult Upload(Stream stream, string fileName)
{
Dictionary<string, string> arguments = new Dictionary<string, string>();
arguments.Add("key", Config.UserAPIKey);
UploadResult result = UploadData(stream, uploadUrl, fileName, "file", arguments, method: HttpMethod.POST);
if (result.Response == null)
{
Errors.Add("Upload failed for unknown reason. Check your API key.");
return result;
}
arguments.Add("linktype", Config.UploadURL);
UploadResult result = UploadData(stream, uploadUrl, fileName, "file", arguments);
if (result.IsSuccess)
{
result.URL = URLHelpers.CombineURL(Config.UploadURL, result.Response);
LithiioResponse response = JsonConvert.DeserializeObject<LithiioResponse>(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; }
}
}