mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-10 14:45:41 +12: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 |
|
@ -25,7 +25,7 @@ You should have received a copy of the GNU General Public License
|
||||||
|
|
||||||
// Credits: https://github.com/lithium720
|
// Credits: https://github.com/lithium720
|
||||||
|
|
||||||
using ShareX.HelpersLib;
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
@ -58,7 +58,7 @@ public Lithiio(LithiioSettings config)
|
||||||
Config = 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/" };
|
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>();
|
Dictionary<string, string> arguments = new Dictionary<string, string>();
|
||||||
arguments.Add("key", Config.UserAPIKey);
|
arguments.Add("key", Config.UserAPIKey);
|
||||||
UploadResult result = UploadData(stream, uploadUrl, fileName, "file", arguments, method: HttpMethod.POST);
|
arguments.Add("linktype", Config.UploadURL);
|
||||||
|
UploadResult result = UploadData(stream, uploadUrl, fileName, "file", arguments);
|
||||||
if (result.Response == null)
|
|
||||||
{
|
|
||||||
Errors.Add("Upload failed for unknown reason. Check your API key.");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.IsSuccess)
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class LithiioResponse
|
public class LithiioResponse
|
||||||
{
|
{
|
||||||
public string url { get; set; }
|
public bool Success { get; set; }
|
||||||
public List<string> errors { get; set; }
|
public string URL { get; set; }
|
||||||
}
|
public string Error { get; set; }
|
||||||
|
|
||||||
internal class LithiioFile
|
|
||||||
{
|
|
||||||
public string url { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue