Problem With Downloaded JPEG Files

Bill Norris

Active Member
Licensed User
Longtime User
I am utilizing the following code to successfully download a set if jpg files from web server. All of the image files download successfully, but something is wrong, as they are not being recognized as jpgs by the device. They will not load in gallery (just a blank screen), and when I try to access them using LoadBitMap, I get Error Loading Bitmap. Hopefully someone can help me figure out the problem.

B4X:
Sub get_images
   HttpUtils.CallbackActivity = "Main" 'Current activity name.
    HttpUtils.CallbackJobDoneSub = "JobDone"
    'HttpUtils.Download("Job1", FileUrl)
   Dim file_to_add As String
   file_list.Initialize
   cursor1=sql1.ExecQuery("Select * from images")
   For i=0 To cursor1.RowCount-1
      cursor1.Position=i
      file_to_add="http://mywebserver/images/" & """" & cursor1.GetString("IMAGE_FILE") & """"
      file_list.Add(file_to_add)
   Next   
   HttpUtils.DownloadList("Job2", file_list)
   
End Sub

Sub JobDone (Job As String)
   
   Dim link As String
   Dim file_name As String
   
   For i = 0 To HttpUtils.Tasks.Size - 1
             link = HttpUtils.Tasks.Get(i)
      file_name=link.SubString(27)  'extracts just the filename from file_to_add
      File.Copy2(HttpUtils.GetInputStream(link),File.OpenOutput(File.DirDefaultExternal,file_name,False))
                  Log(link & ": success=" & HttpUtils.IsSuccess(link))
   Next
   Msgbox("DONE","")
End Sub
 

Bill Norris

Active Member
Licensed User
Longtime User
RE:

Thanks for that. Apparently in my own troubleshooting efforts I have managed to change something that I cannot find. It is now pausing at req.InitializeGet(link) and then crashing. I am getting the following error in the log.

httputilsservice_processnexttask (B4A line: 62)
req.InitializeGet(link)
java.lang.IllegalArgumentException: Illegal character in scheme at index 0: (ArrayList) [http://www.servername.com/tablet/labels/grace_fam_cab.jpg, http://www.servername.com/tablet/labels/col_solare.jpg]

I was running this app all day yesterday without this error.
 
Upvote 0
Top