Hi,
I am working on an application in which i need to fetch some images from internet. I want to do it asynchronusly as not all the images are used at the same time and i do not want my application to halt for some time. But the problem is roUrlTransfer.AsyncGetToFile is not creating file in tmp directory. I have add my async function in urlUtils.brs and here is the code:
It does not work when i do this:
function http_async_get_to_file(filename as String)
m.Http.EnableFreshConnection(true) 'Don't reuse existing connections
res = m.Http.AsyncGetToFile(filename)
end function
but it does work when i do this:
function http_async_get_to_file(filename as String)
m.Http.EnableFreshConnection(true) 'Don't reuse existing connections
res = m.Http.AsyncGetToFile(filename)
if (res)
event = wait(0, m.Http.GetPort())
if type(event) = "roUrlEvent"
else if event = invalid
m.Http.AsyncCancel()
return false
endif
endif
return true
end function
and i am calling this function like this:
for i = 1 to m.adImageCount - 1
asyncGetImage(m.content.adImageUrls.GetEntry(i))
end for
function asyncGetImage(url As string)
fileName = url
while fileName.Instr("/") <> -1
fileName = fileName.Mid(fileName.Instr("/") + 1)
end while
http = NewHttp(url)
print http.AsyncGetToFile("tmp:/" + fileName)
end function
So can you please guide why it is not working in completely async way (1st implementation)?
I am using the images after 20 seconds so this cannot be the case that images could not be downloaded as in 2nd implementation 1 image takes only 1 second or 2.