新建一个脚本文件
POST /new_script_file HTTP/1.1
{"filename":"文件名", "data":"文件内容"}
{"code":0,"message":"操作成功"}
{"code":4,"message":"无法写入文件"}
{"code":11,"message":"文件或目录已存在"}
{"code":8,"message":"参数错误"}
- 电脑端新建一个脚本文件示例(适用于 Python 2.7.x):
import httplib, json, base64
luaf = open('r:/123.lua', 'r')
luatext = luaf.read()
conn = httplib.HTTPConnection("192.168.31.72:46952")
conn.request("POST", "/new_script_file", json.dumps({
"filename":"123.lua",
"data":base64.b64encode(luatext)
}))
response = conn.getresponse()
if response.status == 200:
ret = json.loads(response.read())
print ret['message']
else:
print response.status, response.reason
print response.read()
conn.close()
- 说明
- 该接口文件操作的根目录为
/var/mobile/Media/1ferver/lua/scripts/
- 如果脚本是二进制数据比如加密的脚本,则需要将脚本内容使用 base64 算法编码