long timeout = 30000;
Logger.info("Getting options...");
Scriptable config = (Scriptable) args[0];
Logger.info("Setting core options...");
String url = (String) config.getField("url");
String filePath = (String) config.getField("file");
String fileKey = (String) config.getField("fileKey");
String mimeType = (String) config.getField("mimeType");
Object cTimeout = config.getField("timeout");
Logger.info("Getting headers and params...");
Object sHeaders = config.getField("headers");
Object sParams = config.getField("params");
if (mimeType.equals(UNDEFINED)) {
mimeType = null;
}
if (!cTimeout.equals(UNDEFINED)) {
timeout = ((Integer) cTimeout).intValue();
}
Logger.info("Setting headers and extra params...");
try {
headers = objectToHashtable(sHeaders);
params = objectToHashtable(sParams);
} catch(Throwable e) {
Logger.error("Error setting custom params and headers..." + e.getMessage());
}
_successCallback = (ScriptableFunction) config.getField("success");
_errorCallback = (ScriptableFunction) config.getField("error");
Logger.info("Beginning upload...");
new UploadRunnable(url, fileKey, params, filePath, mimeType, timeout, headers, _transports, _successCallback, _errorCallback);
}