Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not http then
- print("HTTP API is disabled")
- return false
- end
- local destination = "song"
- local url = ({...})[1]
- local httpHandle = http.get(url)
- if not httpHandle then
- print("Error downloading file")
- return false
- end
- if not fs.exists(destination) then fs.makeDir(destination) end
- if not fs.isDir(destination) then
- print("Destination must be a directory")
- return false
- end
- local fileHandle = fs.open(destination .. "/" .. fs.getName(url), "w")
- if not fileHandle then
- print("Error opening file")
- return false
- end
- fileHandle.write(httpHandle.readAll())
- httpHandle.close()
- fileHandle.close()
- print("Done")
Add Comment
Please, Sign In to add comment