Image Uploader Scripting API
Image Uploader Scripting API


  1. Introduction
  2. Example
  3. Functions to implement
  4. Global functions
  5. Upload filter script
  6. Parsing HTML with gumbo-query


Image Uploader is using scripts written in Squirrel 3 language. Squirrel is a high level imperative, object-oriented programming language, designed to be a light-weight scripting language that fits in the size, memory bandwidth, and real-time requirements of applications like video games.

Squirrel 3.0 reference manual
Squirrel 3.0 Standard Libraries manual

Scripts should be saved in utf-8 encoding in files with .nut extension and placed in the Data/Scripts directory.


test <- "example"; // global variable
function UploadFile(pathToFile, options)
nm.addQueryParamFile("file", pathToFile, ExtractFileName(pathToFile),"");
nm.addQueryParam("submit", "Upload file!");
local response = nm.responseBody(); // 'local' it's like javascript's 'var' but only for local variables
local directUrl = regex_simple(response, "\\[IMG\\](.+)\\[/IMG\\]",0);
return 1; //успех
function regex_simple(data,regStr,start)
local ex = regexp(regStr);
local res = ex.capture(data, start);
local resultStr = "";
if(res != null){
resultStr = data.slice(res[1].begin, res[1].end);
return resultStr;
function GetFolderList(list)
// Ваш код
return 1; //успех
function CreateFolder(parentAlbum,album)
// Ваш код
return 1; //успех
function ModifyFolder(album)
// Ваш код
return 1; //успех
// Функция, возвращающая список видов ограничений доступа к альбому:
// приватный, общедоступный, только для друзей и т.п.
// @return array
return ["ТипДоступа1", "ТипДоступа2"];

You have to implement at least one function — UploadFile.
If you want to support album listing/creating/modifying, you have to implement also GetFolderList, CreateFolder, ModifyFolder, GetFolderAccessTypeList.

nm - global object - an instance of NetworkClient
ServerParams - global object - an instance of ServerSettingsStruct

Parsing HTML with gumbo-query

local txt = "<h1><a id=\"logo\">some link</a></h1>";
local doc = Document(txt);
print(doc.find("h1 a").text()+"\r\n");
print(doc.find("h1 a").length()+"\r\n");
txt = nm.responseBody();
doc = Document(txt);
doc.find("a").each( function(index,elem) {