Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Binge Watcher

Downloading images to tmp

To reduce latency, I'm looking to pre-cache images used in a Poster node. 
When trying to write to tmp:/ it shows the filename with a ".tmp" extension and then disappears. I assume this means the file is not downloading properly..  Any idea what the issue could be?

From my screen: (this loops every 5 seconds with a new URL)

m.downloadTask = createObject("roSGNode", "urlgrabber")
m.downloadTask.contenturi = url
m.downloadTask.control = "RUN"

From my download Task:

mypath = CreateObject("roPath",
fileObj = myPath.Split()

print "DOWNLOADING: ";
UT = createObject("roUrlTransfer")
UT.AsyncGetToFile( "tmp:/" + fileObj.filename )

fs = CreateObject("roFileSystem")
fslist = fs.GetDirectoryListing("tmp:/")
print fs.Stat("tmp:/" + fileObj.filename + ".tmp")
print "FILESYSTEM: "; fslist

All i ever get it the following:


<Component: roAssociativeArray> =
    ctime: <Component: roDateTime>
    hidden: false
    mtime: <Component: roDateTime>
    permissions: "rw"
    size: 0
    type: "file"
FILSYSTEM: <Component: roList> =

0 Kudos
Roku Guru

Re: Downloading images to tmp

You are doing AsyncGetToFile()... why?
Try a simple GetToFile and that will likely solve your issue.
(Speculation: you start async download but then your thread promptly completes, roUrlTranfer object gets disposed of - and the linked transfer is canceled. The thread will have to hang around checking for events from async xfer - or you can just use the synchronous method, that blocks till xfer is complete)
0 Kudos
Binge Watcher

Re: Downloading images to tmp

I was having issues with GetToFile() as well. I did the AsyncGetToFile as I was thinking this would move the download to the background vs. having to wait. Is this not the correct thinking?
Figured out I was missing:  msg = wait(0, port).  Once I added this, the download was successful.

This all seems really messy to cache some images vs what "roSlideShow" used to do. I think it cached 5-6 images in advance.  I'm I going about this wrong, or is there a better, more obvious way?

Thanks for the help.
0 Kudos