Appearance
ReadFile 
根据文件路径读取文件内容,返回文件的文本内容。
业务属性 
| 属性 | 含义 | 输入限定 | 示例值 | 
|---|---|---|---|
| enable | 是否启用该控件,未启用时不编译 | 选择值 | 启用 | 
| name | 控件返回值命名 | 常量 | Config | 
| text | 与控件关联的文本 | 常量 | getConfig | 
| filePath | 文件绝对路径 | 常量/流程变量 | #{body.filePath} | 
请使用文件的绝对路径,若使用相对路径可能会抛出找不到文件的异常
使用示例 
假设我们在/usr/local/file路径下有一test.json文件。
文本的内容如下:
txt
This is a sample content from orapisThis is a sample content from orapis输入常量 
控件返回值命名为content,参数输入/usr/local/file/test.json

添加输出控件输出ReadFile控件的返回值content

data属性输入:
json
{
  "content": "#{content}"
}{
  "content": "#{content}"
}使用curl请求接口:
$ curl http://localhost:6636/api/readFile$ curl http://localhost:6636/api/readFile接口返回:
json
{
  "content": "This is a sample content from orapis"
}{
  "content": "This is a sample content from orapis"
}输入指定变量 
参数输入#{body.filePath}

使用curl请求接口:
$ curl http://localhost:6636/api/readFile -d "{ \"filePath\": \"/usr/local/file/test.json\" }"$ curl http://localhost:6636/api/readFile -d "{ \"filePath\": \"/usr/local/file/test.json\" }"接口返回:
json
{
  "content": "This is a sample content from orapis"
}{
  "content": "This is a sample content from orapis"
}