iOS Question Error using job.download

salvadoro

Member
Licensed User
Longtime User
Hi i receive this error when trying to download this image https://taco-drive.com/assets/profile/RES002.jpg

ResponseError: unsupported URL, status code: 0

B4X:
Dim Job As HttpJob
Job.Initialize("Image", Me)
Job.Download("https://taco-drive.com/assets/profile/RES002.jpg")

There is some kind of bug cause the link is right or i doing something wrong
 

aeric

Expert
Licensed User
Longtime User
Here is my version

B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: B4i Example
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 8
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

End Sub

Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
    
    Dim imgProfile As ImageView
    imgProfile.Initialize("imgProfile")
    Page1.RootPanel.AddView(imgProfile, 100dip, 100dip, 100dip, 100dip)
    
    'Dim Job As HttpJob
    'Job.Initialize("Image", Me)
    'Job.Download("https://taco-drive.com/assets/profile/RES002.jpg")
    
    Dim strLink As String = "https://taco-drive.com/assets/profile/RES002.jpg"
    DownloadImage(strLink, imgProfile)
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
    
End Sub

Private Sub Application_Background
    
End Sub

Sub DownloadImage(Link As String, iv As ImageView)
    Try
        Dim job As HttpJob
        job.Initialize("Image", Me)
        job.Download(Link)
        Wait For (job) JobDone(job As HttpJob)
        If job.Success Then
            iv.Bitmap = job.GetBitmap
        Else
            iv.Bitmap = LoadBitmap(File.DirAssets, "noimg.png")
        End If
        job.Release
    Catch
        'Log(LastException)
        iv.Bitmap = LoadBitmap(File.DirAssets, "noimg.png")
    End Try
End Sub
 

Attachments

  • Download.zip
    12.8 KB · Views: 206
Upvote 0
Top