Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to receive files from the client
- local function receiveFilesFromClient()
- local senderID, _, _, _, message = os.pullEvent("modem_message")
- local deviceID = tostring(senderID)
- local files = message[1]
- -- Assuming each file is represented as a string
- for _, file in ipairs(files) do
- local fileContent = fs.open(file, "r")
- if fileContent then
- local content = fileContent.readAll()
- fileContent.close()
- local savePath = "/disk/update_" .. deviceID .. "/" .. fs.getName(file)
- local saveFile = fs.open(savePath, "w")
- saveFile.write(content)
- saveFile.close()
- print("Received file: " .. savePath)
- else
- print("Failed to open file: " .. file)
- end
- end
- end
- -- Main loop to continuously receive files
- while true do
- receiveFilesFromClient()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement