Android Question get image from path of external server

angel

Member
Licensed User
Longtime User
Hello

How to get image from path of external server, this code fault

Code:
Dim link As String = "//folder/various/testimg/logo.png"

Dim job As HttpJob
job.Initialize("j", Me)
job.Download(link)

Sub JobDone(job As HttpJob)
If job.Success Then
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "filename.dat", False)
File.Copy2(job.GetInputStream, out)
out.Close '<------ very important
Else
Log("Error: " & job.ErrorMessage)
End If
job.Release
End Sub
the error is:
java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=map, path=//folder/various/testimg/logo.png
 

Peter Simpson

Expert
Licensed User
Longtime User
@angel you should also watch this tutorial video.

 
Upvote 0

angel

Member
Licensed User
Longtime User
@angel you should also watch this tutorial video.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim link As String = "//folder/various/testimg/logo.png"
    Dim job As HttpJob
    job.Initialize("j", Me)
    job.Download(link)
End Sub

Sub JobDone(job As HttpJob)
    If job.Success Then
        Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "filename.dat", False)
        File.Copy2(job.GetInputStream, out)
        out.Close '<------ very important
    Else
        Log("Error: " & job.ErrorMessage)
    End If
    job.Release
End Sub

The link is a Shared folder of a server, does not work with http or https
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
The link is a Shared folder of a server, does not work with http or https
if you are in the same network (wifi) you can try the SMB library.
okhttputils will not work if you do not have an Webserver running on the PC.
 
Upvote 0
Top