Hello everyone!
I found problem while developing client app: I can’t upload file with json inside. My server shows that there was a post request but can’t get the request’s body. Recently I tried to make this request with network.request but it doesn’t work either. Also callback for request haven’t been called at all.
Here is gist with node.js server:
[gist]5c64cfe1ca4847f01d54[/gist]
Here is function where I make uploading:
[lua]
local function post(data)
local headers = {}
local jsonString = json.encode(data)
print("I’m posting: " … jsonString)
local path = system.pathForFile(“data.json”, system.DocumentsDirectory)
local file = io.open(path, “w”)
file:write(jsonString)
io.close( file )
file = nil
network.upload(
url,
“POST”,
networkListener,
“data.json”,
system.DocumentsDirectory,
“application/json”
)
end
[/lua]
Please suggest ways to solve this problem.