我有这个代码几乎可以在parse.com上传文件到我的班级。我无法在我的代码中获得这行的正确语法message1 [“photo”] = {“name”= urladress,“__ type”:“文件”} ,.
message = {}
local function networkListener2( event )
print (event.response)
end
local function sendresponse( event )
print (event.response)
local urladress = '{ "results": [ '
tables1 = urladress..string.sub(event.response, 0,-2)..'] }'
urladress = json.decode (tables1)
print (urladress.results[1].url)
headers = {}
headers["X-Parse-Application-Id"] = APPID
headers["X-Parse-REST-API-Key"] = RESTAPIKEY
headers["Content-Type"] = "application/json"
local params = {}
params.headers = headers
local message1 = {}
message1["name"] = "Andrew"
message1["photo"] = {"name"=urladress, "__type": "File"},
params.body = json.encode ( message1 )
network.request( "https://api.parse.com/1/classes/photos", "POST", networkListener2, params)
end
local saverecord = function( )
headers = {}
headers["X-Parse-Application-Id"] = APPID
headers["X-Parse-REST-API-Key"] = RESTAPIKEY
headers["Content-Type"] = "image/jpeg"
local params = {}
params.headers = headers
params.bodyType = "binary"
network.upload("https://api.parse.com/1/files/photo.jpg","POST",sendresponse,params,"photo.jpg",system.DocumentsDirectory,"image/jpeg")
end
答案 0 :(得分:0)
parse
不支持直接上传文件。
答案 1 :(得分:0)
您可以使用间接上传,它会为您提供网址并使用该网址。比如
local function onPhotoUpload( event )
local dataTable = { ["photo"] = event.response.url }
end
parse:uploadFile( { ["filename"] = "image.jpg", ["baseDir"] = system.DocumentsDirectory }, onPhotoUpload )