函数:pull_file 下载文件

方法名称:下载文件

方法功能:从中控下载文件到设备

调用方法

ok,err = ts_enterprise_lib:pull_file(local_file,remote_file);

参数 类型 必填 说明
local_file string 设备的文件路径
remote_file string 中控的文件路径,
可以是相对中控器文件夹的相对路径,也可以是绝对路径
返回值 类型 说明
ok boolean 操作结果,成功返回 true,失败返回 false
err string 当 ok 等于 true,无返回值;当 ok 等于 false,返回错误原因

函数用例

--企业版库为企业版专用库请勿在除企业版外的产品使用,此库已内置,无需下载
--如果提示没有 ts_enterprise_lib 库请重启企业版客户端服务再试
ts_enterprise_lib = require("ts_enterprise_lib")
assert(ts_enterprise_lib,"无法引入企业专用库")
--中控器的相对路劲
local remote_file = "abc.txt" 
local filedata = [[
1111 
2222 
3333
]]
local mode = "a"
--写入文件
local ok,msg = ts_enterprise_lib:remote_file_save(remote_file,filedata,mode)
if ok then
    toast("写入成功",5)
    nLog("写入成功")
    --下载文件
    --下载到手机上的文件路径
    local  local_file =  userPath().."/res/ceshixin.txt"  
    local ok,err = ts_enterprise_lib:pull_file(local_file,remote_file)
    if ok then
        toast("下载成功",5)
        nLog("下载成功")
    else
        toast("文件下载失败,失败原因:"..err,5)
        nLog("文件下载失败,失败原因:"..err)
    end
else
    toast("写入失败,失败原因:"..msg,5)
    nLog("写入失败,失败原因:"..msg)
end
--测试速度结果:80 M 文件 11 - 18 秒
--此功能需要配合 1069 以上版本中控器方可使用
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""