2017-09-10 03:06:40 +10:00
|
|
|
local tA = {...}
|
|
|
|
local url = tA[1]
|
|
|
|
local path = tA[2]
|
|
|
|
local R=component.internet.request(url)
|
|
|
|
if not R then return false end
|
|
|
|
local f=io.open(path,"wb")
|
|
|
|
if not f then return false end
|
|
|
|
repeat
|
|
|
|
coroutine.yield()
|
|
|
|
until R.finishConnect()
|
2017-09-23 11:24:37 +10:00
|
|
|
local code, msg = R.response()
|
|
|
|
if code ~= 200 then
|
|
|
|
return false, code, msg
|
|
|
|
end
|
2017-09-10 03:06:40 +10:00
|
|
|
repeat
|
|
|
|
coroutine.yield()
|
2017-10-09 04:29:47 +11:00
|
|
|
local t,c,C = event.get()
|
|
|
|
if t == "key" and c == 3 and C == 46 then break end
|
2017-09-10 03:06:40 +10:00
|
|
|
ns = R.read(2048)
|
|
|
|
f:write(ns or "")
|
|
|
|
until not ns
|
|
|
|
f:close()
|