Configuration for Lua Script Execution
You must configure the transfer server using the aspera.conf file in order execute Lua scripts automatically.
First you add a <transfer>
element to
aspera.conf. Then, within the
<transfer>
element, you add sub-elements to identify the
transfer events and the scripts. The scripts can be identified by pathname, or the
base64 encoded version of the scripts (or path to the scripts) can be used directly.
Scripts can access transfer session data, which is stored in a Lua table
(env_table[]
). They can also make use of several functions that
are provided to facilitate filesystem operations, logging, and aborting a session.
Event Types
- session start
- session stop
- session progress
- file start
- file stop
Event Type and Script Specification
Within the <transfer>
element, you use sub-elements that identify
the type of event and the script that will be run at that event. You can identify
the script by its pathname, or you can use the base64 encoding of the script itself.
A script can be used for more than one event, whether referenced by its filepath or
included base64 encoded format.
To simplify developing your script, you may find it useful to temporarily specify the script by pathname as well as use base64 encoding of the script for a given execution event (in separate specification lines).
If both filepath and base64 specifications are used, the pathname-based specification will override a base64 specification.
Session Start |
---|
<lua_session_start_script_base64></my_lua_session_start_script_base64> |
<lua_session_start_script_path></my_lua_session_start_script_path> |
Session Stop |
---|
<lua_session_stop_script_base64></my_lua_session_stop_script_base64>
|
<lua_session_stop_script_path></my_lua_session_stop_script_path> |
Session Progress |
---|
<lua_session_progress_script_base64></my_lua_session_progress_script_base64>
|
<lua_session_progress_script_path></my_lua_session_progress_script_path>
|
File Start |
---|
<lua_file_start_script_base64></my_lua_file_start_script_base64> |
<lua_file_start_script_path></my_lua_file_start_script_path> |
File Stop |
---|
<lua_file_stop_script_base64></my_lua_file_stop_script_base64> |
<lua_file_stop_script_path></my_lua_file_stop_script_path> |
Configuration Examples
Consider, for example, a file called myluascript, which contains this code:
lua_log("Hello from lua-land")
<transfer>
<lua_session_start_script_base64>bHVhX2xvZygiSGVsbG8gZnJvbSBsdWEtbGFuZCIp</lua_session_start_script_base64>
</transfer>