download.js 392 B

123456789101112131415161718192021
  1. /*
  2. Download.js
  3. Download a file given
  4. - link
  5. - filepath
  6. - filename
  7. */
  8. requirelib("http");
  9. //Create the download folder if not exists
  10. requirelib("filelib");
  11. if (!filelib.fileExists(filepath)){
  12. filelib.mkdir(filepath);
  13. }
  14. //Download the file to target location
  15. http.download(link, filepath, filename);
  16. HTTP_HEADER = "application/json; charset=utf-8";
  17. sendResp('"OK"');