diff --git a/Data/Favicons/imghippo.com.ico b/Data/Favicons/imghippo.com.ico new file mode 100644 index 00000000..00c5b67a Binary files /dev/null and b/Data/Favicons/imghippo.com.ico differ diff --git a/Data/Scripts/imghippo.nut b/Data/Scripts/imghippo.nut new file mode 100644 index 00000000..735c4696 --- /dev/null +++ b/Data/Scripts/imghippo.nut @@ -0,0 +1,38 @@ +function UploadFile(fileName, options) { + local key = ServerParams.getParam("apiKey"); + if (key == "") { + WriteLog("error", "[imghippo.com] API key not set!"); + return 0; + } + local name = ExtractFileName(fileName); + local mime = GetFileMimeType(name); + nm.setUrl("https://api.imghippo.com/v1/upload"); + nm.addQueryParam("api_key", key); + nm.addQueryParam("format", "json"); + nm.addQueryParamFile("file", fileName, name, mime); + nm.doUploadMultipartData(); + + if (nm.responseCode() == 200) { + local sJSON = nm.responseBody(); + local t = ParseJSON(sJSON); + if (t != null) { + if ("success" in t && t.success) { + options.setViewUrl(t.data.view_url); + options.setDirectUrl(t.data.url); + return 1; + } else { + if ("message" in t && t.message != null) { + WriteLog("error", "[imghippo.com] " + t.message); + } + } + } + } + + return 0; +} + +function GetServerParamList() { + return { + apiKey = "API key" + } +} \ No newline at end of file diff --git a/Data/servers.xml b/Data/servers.xml index c67861db..464f1747 100644 --- a/Data/servers.xml +++ b/Data/servers.xml @@ -115,6 +115,7 @@ + @@ -432,6 +433,11 @@ + + + + +