Issue
My channel package is over 4mb.
Environment
SDK
Answer
To download content into a local cache, you can use this:
xfer=createobject("roUrlTransfer")
xfer.SetCertificatesFile("common:/certs/ca-bundle.crt")
xfer.seturl("https://my.server.com/image.jpg")
xfer.gettofile("cachefs:/image_I_want_to_cache.jpg")
You will need to check if the file is in the cachefs before downloading.
Here is some sample code:
xfer.seturl(image.url.gettext())
'find last slash
txtstr=image.url.gettext()
txtstr=mid(txtstr,instr(txtstr,"//")+1)
while instr(txtstr,"/") > 0
txtstr=mid(txtstr,instr(txtstr,"/")+1)
end while
ttimer=createobject("rotimespan")
ttimer.mark()
if not fs.exists("cachefs:/"+txtstr) then
print "not in cache, get image"
xfer.seturl(image.url.gettext())
xfer.gettofile("cachefs:/"+txtstr)
print "transfer time";ttimer.totalmilliseconds()
else
print "found in cache!!!"
end if
print "transfer time";ttimer.totalmilliseconds()
Additional Resources
Comments
0 comments
Please sign in to leave a comment.