一种方法是在到 /files/{file_path} 的 POST 上使用服务器端脚本(在本例中为 V8J)。转到管理应用程序,脚本选项卡,然后按照以下路径处理事件...
Process Event Scripts > files > files.{file_path} > [POST] files.{file_path} > files.{file_path}.post.post_process
试试下面的脚本...
// event.resource is the {file_path} part,
// including any folders from root, i.e. my/path/file.txt
var_dump(event.resource);
// Create a record that you want to post to a table,
// using the "todo" table for example, setting "name" to the file path
// "mysql" is my db service name
var record = {"resource": [ {"name": event.resource, "complete": false } ] };
var result = platform.api.post('mysql/_table/todo', record);
var_dump(result);
// result contains a resource array with the id of the record created
// like {"resource": [ {"id": 5} ] }