Download Several Images from site

Sytek

Active Member
Licensed User
I have the name of images in a database and the images on a folder.
I need to download the images from the online folder into my device

I test the attached Downloadservice but some files where downloaded in 0 KB

How can i download the images into my device completely? , 'cause only the last file name is download it completely?
Thank's in advance

:confused:
 
Last edited:

Sytek

Active Member
Licensed User
Hi Erel Happy New Year. Thank's for the reply.

I need to download images from my folder's site.

Here's an example that i took from Httputils2; But i cannot make it work. :sign0148:

Thank's in advance!
 
Last edited:
Upvote 0

Sytek

Active Member
Licensed User
Hi Erel.
I Don't know if this is correct but Changing this line of code the images are downloaded completely.
I mean if this is not correct 'cause i don't know if i will have problems with the Dim's of Jobs.
...I'll Do some tests tomorrow.
...This One
B4X:
out = File.OpenOutput(File.DirDefaultExternal,mimage,False )
..With This One
B4X:
out = File.OpenOutput(File.DirDefaultExternal,"mimage"&Job.Jobname&".jpg",False )

Note: The Name of the files are not relevant to me; 'Cause I'm going to replace them with the new ones

Best Regards!
 
Upvote 0

Informatix

Expert
Licensed User
I have the name of images in a database and the images on a folder.
I need to download the images from the online folder into my device

I test the attached Downloadservice but some files where downloaded in 0 KB

How can i download the images into my device completely? , 'cause only the last file name is download it completely?
Thank's in advance

:confused:

As an UltimateListView customer, you can use the download function of the ULV_Utils library:
B4X:
Dim IL As ImageLoader
Dim Bmp As Bitmap
Bmp = IL.GetBitmapFromInternet(URL, True)
Then you save your bitmap in a file.
 
Upvote 0

Sytek

Active Member
Licensed User
Erel Can you post the code in JobDone?
...Yes!! I Will!!

Informatix As an UltimateListView customer, you can use the download function of the ULV_Utils library:
...I'm going to check this one

Informatix Thank's for the New year's Gift.
...And Happy New Year to everyone!!!

Best regards.
 
Upvote 0

Sytek

Active Member
Licensed User
Hi Erel!
I exported and updated the zip file with the project with the jobdone

Thank's
Best Regards!
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Why do you copy the bitmap at all?

I've cleaned your code:
B4X:
Sub Process_Globals
    
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
   For Each s As String In Array As String("save.jpg", "Button-Add-icon.png", "ruta.jpg", _
      "excel.png")
      Dim job As HttpJob
      job.Initialize(s, Me)
      job.Download("http://www..mx/uploads/" & s)
   Next
End Sub

Sub JobDone (Job As HttpJob)
   Log("JobName = " & Job.JobName &" -Image Download Name = "& ", Success = " & Job.Success)
   If Job.Success = True Then
      'is this really needed ???
       Dim out As OutputStream
       out = File.OpenOutput(File.DirDefaultExternal, Job.JobName ,False )
       File.Copy2(Job.GetInputStream, out)
       out.Close
       Activity.SetBackgroundImage(Job.GetBitmap)
   Else
      Log("Error: " & Job.ErrorMessage)
      ToastMessageShow("Error: " & Job.ErrorMessage, True)
   End If
   Job.Release
End Sub
 
Upvote 0

Sytek

Active Member
Licensed User
Thank's I forgot to remove my site name would you please remove it?
Thank's in advance.

...So if I want to scan my query i'll just do and array with it..right?
 
Upvote 0

Sytek

Active Member
Licensed User
B4X:
For Each s As String In Array As String("save.jpg", "Button-Add-icon.png", "ruta.jpg", _
        "excel.png")
        Dim job As HttpJob
        job.Initialize(s, Me)
        job.Download("http://www..mx/uploads/" & s)
    Next
..This array; I mean the "save.jpg" would be a field name from a cursor. As I mentioned before the name of the images are saved in a database field name.
 
Upvote 0
Top