-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update version info
- Loading branch information
Showing
5 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters