HttpUtils for download public Dropbox files?

psdos

Active Member
Licensed User
Longtime User
I test this code but dont go.

B4X:
'Activity module
Sub Process_Globals
   Dim fileUrl As String
   fileUrl = "http://dl.dropbox.com/u/xxxxxx/db.db"
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
   HttpUtils.CallbackActivity = "Main"
   HttpUtils.CallbackJobDoneSub = "JobDone"
   HttpUtils.CallbackUrlDoneSub = "UrlDone"
End Sub

Sub Activity_Resume
   'Check whether a job has finished while the activity was paused.
   If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub
Sub UrlDone(Url As String)
   Log(Url & " done")
End Sub
Sub JobDone (Job As String)
         If HttpUtils.IsSuccess(fileUrl) Then 
            Log("Base de datos encontrada en la web")
            HttpUtils.Download("GET Job1", fileUrl)
            Dim In As InputStream, Out As OutputStream
            In = HttpUtils.GetInputStream("GET Job1")
            Out = File.OpenOutput(File.DirRootExternal & "/" & "external_sd", "db.db", True)
            File.Copy2(In, Out)
            Out.Close
            HttpUtils.Complete = False 'Turn off the complete flag so we won't handle it again if the activity is resumed.
            ExitApplication
         End If
End Sub

is possible download any file from public Dropbox folder?

Thanks.
 

psdos

Active Member
Licensed User
Longtime User
In this code all is ok.


B4X:
'Activity module
Sub Process_Globals
   Dim imageUrl As String
   imageUrl = "http://dl.dropbox.com/u/xxxxxxxx/db.db"
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("Main")
End Sub

Sub Activity_Resume
   'Check whether a job has finished while the activity was paused.
   If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub

Sub UrlDone(Url As String)
   Log(Url & " done")
End Sub

Sub JobDone (Job As String)
   If HttpUtils.IsSuccess(imageUrl) Then 
    Dim out As OutputStream
   out = File.OpenOutput(File.DirRootExternal & "/" & "external_sd", "db.db", True)
   File.Copy2(HttpUtils.GetInputStream(imageUrl), out)
   out.Close
    End If
End Sub

Sub Button1_Click
   HttpUtils.CallbackActivity = "Main" 'Current activity name.
    HttpUtils.CallbackJobDoneSub = "JobDone"
   HttpUtils.CallbackUrlDoneSub = "UrlDone"
    HttpUtils.Download("Job1", imageUrl)
End Sub

Anyone has sample code for progressbar funtion and so know how many information is copied at device?

Thanks.
 
Last edited:
Upvote 0

psdos

Active Member
Licensed User
Longtime User
Erel, now the problem is with add update funtion at my program, how check size, time, date from file in free dropbox space, and if it is different at my DB, then update with HttpUtils.

Thanks for all.
 
Upvote 0

psdos

Active Member
Licensed User
Longtime User
Do you know how is it? Never use her API, some sample code help me.

Thanks.
 
Last edited:
Upvote 0
Top