This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
rex41043's profile picture

HTTP API file downloader?

Started by rex41043, 13 April 2012 - 06:03 AM
rex41043 #1
Posted 13 April 2012 - 08:03 AM
I have been working on a site like pastebin and I have been trying to get the HTTP stuff to download a file form it.
but so far i have had no luck is there eny 1 out there that can help?
i have a file set up u can test on: http://ccfs.nuclear-games.net63.net/files/file_test
Xtansia #2
Posted 13 April 2012 - 10:11 AM

local tmpF = http.get("http://ccfs.nuclear-games.net63.net/files/file_test")
local txt = tmpF:readAll()
print(txt)
rex41043 #3
Posted 13 April 2012 - 10:24 AM

local tmpF = http.get("http://ccfs.nuclear-games.net63.net/files/file_test")
local txt = tmpF:readAll()
print(txt)
thanx now to figer out how to get it to save into a file
Luanub #4
Posted 13 April 2012 - 10:43 AM
like this..

local file = io.open("test_file.txt", "w")
file:write(txt)
file:close()
rex41043 #5
Posted 13 April 2012 - 11:01 AM
like this..

local file = io.open("test_file.txt", "w")
file:write(txt)
file:close()
sweet I think this will work