I have a URL (.cgi script) which is returning a .jpeg file. I can copy/paste the URL into my browser and see the image without issue.
But... when I pull that same URL via this code, it returns an INVALID event immediately.
' agent for transferring files
agent = CreateObject("roUrlTransfer")
agent.SetUrl(settings.Url)
print "About to AsyncGetToFile: "; settings.Url; " "; tmpFile
' get it
if (agent.AsyncGetToFile(tmpFile) = false) then
print "AsyncGetToFile never even started!"
end if
event = wait(30000,agent.GetMessagePort())
if type(event) = "roUrlEvent"
print "***";event.GetInt();
print "***";event.GetResponseCode();
print "***";event.GetFailureReason();
print "***";event.GetSourceIdentity()
else if event = invalid
print "AsyncGetToFile timeout"
agent.AsyncCancel()
else
print "AsyncGetToFile unknown event: "; event
endif
I've seen some code using agent.GetPort() instead but the reference at
http://sdkdocs.roku.com/display/sdkdoc/roUrlTransfer only lists GetMessagePort()
Any help is appreciated.
****************************************
SOLVED
****************************************
agent = CreateObject("roUrlTransfer")
agentPort = CreateObject("roMessagePort")
agent.SetMessagePort(agentPort)
agent.SetUrl(settings.Url)