Hi!
I can’t get a download of the file by link in the emulator.
On the python program everything downloads:
import urllib.request
destination = 'testpict2.jpg'
url = 'https://upload.wikimedia.org/wikipedia/commons/5/5e/Messier83_-_Heic1403a.jpg'
urllib.request.urlretrieve(url, destination)
on Solar2d is downloaded only at the reference of the type
'https://i.postimg.cc/wtbm4xr9/2016-singapur-rochor-wi -tynia-sri-krishnan-21.jpg ’
by other links the error is not issued, but not downloaded.
here is the code
local function networkListener(event)
if (event.isError) then
print("Network error: ", event.response)
local alert = native.showAlert("Network error:", event.response, { "Close app" },
function() native.requestExit() end)
elseif (event.phase == "began") then
if (event.bytesEstimated <= 0) then
print("Download starting, size unknown")
else
print("Download starting, estimated size: " .. event.bytesEstimated)
end
elseif (event.phase == "progress") then
if (event.bytesEstimated <= 0) then
print("Download progress: " .. event.bytesTransferred)
else
print("Download progress: " .. event.bytesTransferred .. " of estimated: " .. event.bytesEstimated)
end
elseif (event.phase == "ended") then
print("Download complete, total bytes transferred: " .. event.bytesTransferred)
local pict = display.newImageRect("pict.jpg", system.DocumentsDirectory, display.actualContentWidth,
display.actualContentHeight)
pict.anchorX = 0
pict.anchorY = 0
pict.x = 0 + display.screenOriginX
pict.y = 0 + display.screenOriginY
end
end
local params = {}
params.progress = "download"
params.response = {
filename = "pict.jpg",
baseDirectory = system.DocumentsDirectory
}
os.remove(system.pathForFile("pict.jpg", system.DocumentsDirectory))
--url = "https://upload.wikimedia.org/wikipedia/commons/5/5e/Messier83_-_Heic1403a.jpg?download"
--url = "https://upload.wikimedia.org/wikipedia/commons/9/92/Fortifications_Rhodes.jpg"
--url = "https://www.dropbox.com/scl/fi/1z45uibsllyp2614a2znz/p001.jpg?rlkey=6hpeqoqd4ptf44wumpqc5lwup&st=ps4yk3yj&dl=1"
url = "https://i.postimg.cc/wTBm4xR9/2016-Singapur-Rochor-wi-tynia-Sri-Krishnan-21.jpg"
network.download(
url,
"GET",
networkListener,
params,
"pict.jpg",
system.DocumentsDirectory
)
to console:
15: 12.176 Download Side: 1005
15: 26: 12.176 Download Progress: 1005 of Estimated: 1005
15: 12.176 Download Complete, Total Bytes Transferred: 1005
15: 12.176 Warning: D: \ Work \ TestDownLoad \ Main.lua: 24: 24: 24: 24: FA ILED To find IMAGE ’ PICT.JPG ’
15: 26: 12.176 error: runtime error
what am I doing wrong?