3

I'm trying to download and then save the contents to a xml file. The code I got is:

local filePath = currentDir().."/file.xml"

local http  = require("socket.http")
local xFile = io.open(filePath, "w")
local save = ltn12.sink.file(xFile)

http.request{addr, sink = save }
print("Done!")

It runs but the file is still empty. Can I get some help here please?

user2779657
  • 99
  • 2
  • 7

1 Answers1

4

Its a syntactical mistake. You mixed two styles of calling http.request. Use

http.request{url = addr, sink = save } 
robinkc
  • 1,318
  • 8
  • 12