Android Question [SOLVED] Problem with downloading big file

parijs

Active Member
Licensed User
Longtime User
I have to download a big file for my app (193MB)
With ftp it takes too long and my log says ' Ignoring event (too many queued events: ftp_downloadprogress).

Download by website is faster and works for me, but not for customers.
They get this error
sub: httpjob_getinputstream (java line: 143)
java.oi.FileNotFoundException: /data/user/0/com.hr.ketels/cache/2 (no such file or directory)

The code that I use is

#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region

Sub Process_Globals
Private link1 As String = "http://visitparijs.nl/appdl/ketels.zip"
End Sub

Sub Globals
Dim ProgressBar1 As ProgressBar
Dim Label1 As Label
Dim btnDownload As Button
' Dim btnCancel As Button
Dim GetFilename As String
Dim Arc As Archiver
Private Buttonback As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)

GetFilename = "ketels.zip"
Activity.LoadLayout("1")
End Sub

Sub btnDownload_Click
Dim dd As DownloadData
dd.url = link1
dd.EventName = "dd"
dd.Target = Me
CallSubDelayed2(DownloadService, "StartDownload", dd)
End Sub

Sub dd_Progress(Progress As Long, Total As Long)
ProgressBar1.Progress = Progress / Total * 100
Label1.Text = NumberFormat(Progress / 1024, 0, 0) & "KB / " & _
NumberFormat(Total / 1024, 0, 0) & "KB"
End Sub

Sub dd_Complete(Job As HttpJob)
Log("Job completed: " & Job.Success)

Dim o As OutputStream
o = File.OpenOutput(File.DirDefaultExternal, "ketels.zip", False)

File.Copy2(Job.GetInputStream, o)
o.Close
Job.Release
File.Copy(File.DirDefaultExternal,"ketels.zip", File.DirRootExternal, "HrKetels/ketels.zip")

Arc.Unzip(File.DirRootExternal,"HrKetels/ketels.zip", File.DirRootExternal & "/HrKetels",Null)

Buttonback.Visible = True
End Sub

Sub btnCancel_Click
CallSubDelayed2(DownloadService, "CancelDownload", link1)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Buttonback_Click
Activity.Finish
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
1. You should use CODE Tags when posting CODE. Not Quote Tags
2. Use file Export as zip and upload the project.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Download by website is faster and works for me, but not for customers.
They get this error
sub: httpjob_getinputstream (java line: 143)
java.oi.FileNotFoundException: /data/user/0/com.hr.ketels/cache/2 (no such file or directory)

The "FileNotFoundException" may mean that the file right permission is missing for the customers.

Regards,

Anand
 
Upvote 0

parijs

Active Member
Licensed User
Longtime User
Hi Anand,

They have right permission.

B4X:
    rp.CheckAndRequest(rp.PERMISSION_CALL_PHONE)
    Wait For Activity_PermissionResult (Permission As String, result As Boolean)
    
    rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult (Permission As String, result As Boolean)
    
    If result Then
        File.MakeDir(File.DirRootExternal,"HrKetels")
        File.Copy(File.DirAssets,"storing.db", File.DirRootExternal, "HrKetels/storing.db")
        If File.Exists(File.DirRootExternal, "HrKetels/vitidens111.zip") = False Then
            StartActivity(dl)
        End If

        If File.Exists(File.DirRootExternal, "HrKetels/favo.db") = False Then
            File.Copy(File.DirAssets,"favo.db", File.DirRootExternal, "HrKetels/favo.db")
        End If
        If File.Exists(File.DirRootExternal, "HrKetels/bedrijf.db") = False Then
            File.Copy(File.DirAssets,"bedrijf.db", File.DirRootExternal, "HrKetels/bedrijf.db")
        End If
        
    End If

The DB files are in the directory

Regards,
Zeger
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
I mean, "/data/user/0/com.hr.ketels/cache/2 (no such file or directory)" means access right restriction on web file

Regards,

Anand
 
Upvote 0
Top