http.download.js 421 B

1234567891011121314151617
  1. /*
  2. http.download Download the given file to the given path
  3. */
  4. requirelib("http")
  5. //Download the file
  6. //Usage: URL, save directory, filename (optional)
  7. var success = http.download("https://filesamples.com/samples/audio/mp3/Symphony%20No.6%20(1st%20movement).mp3", "user:/Desktop", "My Music.mp3")
  8. if (success){
  9. sendResp("OK");
  10. }else{
  11. sendJSONResp(JSON.stringify({
  12. error: "Download failed"
  13. }));
  14. }