Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- while true do
- local id, msg = rednet.receive()
- if msg.at == "resourceManager" then
- if msg.command[1] == "downloadFileById" then
- write("downloading '")
- write(msg.url)
- write("'... ")
- print(id)
- local answer = http.get(msg.url)
- if not answer then
- rednet.send(id, { at = "any", command = { "resourceManager", "resourceFailure" },
- resourceId = msg.resourceId })
- else
- rednet.send(id, { at = "any", command = { "resourceManager", "resourceSuccess" },
- resourceId = msg.resourceId,
- data = answer.readAll() })
- end
- answer.close()
- print("done")
- else
- print("unknownCommand: " .. msg.command[1])
- end
- end
- end
Add Comment
Please, Sign In to add comment