"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[9173],{1863:(e,n,l)=>{l.r(n),l.d(n,{assets:()=>a,contentTitle:()=>s,default:()=>u,frontMatter:()=>t,metadata:()=>o,toc:()=>d});const o=JSON.parse('{"id":"XXTLanControl.lua/web-file/download_file","title":"Download Controller File To Device (LCC.web_file.download_file)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/web-file/download_file.md","sourceDirName":"XXTLanControl.lua/web-file","slug":"/XXTLanControl.lua/web-file/download_file","permalink":"/docs/en/XXTLanControl.lua/web-file/download_file","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":120,"frontMatter":{"sidebar_position":120},"sidebar":"tutorialSidebar","previous":{"title":"Append To Controller File (LCC.web_file.appends)","permalink":"/docs/en/XXTLanControl.lua/web-file/appends"},"next":{"title":"Upload Device File To Controller (LCC.web_file.upload_file)","permalink":"/docs/en/XXTLanControl.lua/web-file/upload_file"}}');var r=l(4848),i=l(8453);const t={sidebar_position:120},s="Download Controller File To Device (LCC.web_file.download_file)",a={},d=[{value:"Signature",id:"signature",level:2},{value:"Parameters",id:"parameters",level:2},{value:"Returns",id:"returns",level:2},{value:"Notes",id:"notes",level:2},{value:"Example",id:"example",level:2}];function c(e){const n={blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"download-controller-file-to-device-lccweb_filedownload_file",children:"Download Controller File To Device (LCC.web_file.download_file)"})}),"\n",(0,r.jsx)(n.h2,{id:"signature",children:"Signature"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lua",children:"ok, err = LCC.web_file.download_file(path, target_path, timeout?)\n"})}),"\n",(0,r.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["path",(0,r.jsx)(n.br,{}),"\n","String. Source path on the controller."]}),"\n",(0,r.jsxs)(n.li,{children:["target_path",(0,r.jsx)(n.br,{}),"\n","String. Absolute destination path on the device."]}),"\n",(0,r.jsxs)(n.li,{children:["timeout",(0,r.jsx)(n.br,{}),"\n","Number, optional. Request timeout in seconds, default ",(0,r.jsx)(n.code,{children:"60"}),"."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["ok",(0,r.jsx)(n.br,{}),"\n","Boolean. ",(0,r.jsx)(n.code,{children:"true"})," when the download succeeds, ",(0,r.jsx)(n.code,{children:"false"})," otherwise."]}),"\n",(0,r.jsxs)(n.li,{children:["err",(0,r.jsx)(n.br,{}),"\n","String or ",(0,r.jsx)(n.code,{children:"nil"}),". Error description when the operation fails."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"notes",children:"Notes"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["Downloads a file from the controller and saves it to the device.",(0,r.jsx)(n.br,{}),"\n","Returns ",(0,r.jsx)(n.code,{children:"false"})," if the target directory is missing or the write fails."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lua",children:'local ok, err = LCC.web_file.download_file("/scripts/main.lua", XXT_SCRIPTS_PATH.."/cache.lua")\nif not ok then\n    error(err)\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(c,{...e})}):c(e)}},8453:(e,n,l)=>{l.d(n,{R:()=>t,x:()=>s});var o=l(6540);const r={},i=o.createContext(r);function t(e){const n=o.useContext(i);return o.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function s(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:t(e.components),o.createElement(i.Provider,{value:n},e.children)}}}]);