Android Tutorial Download huge files with HttpUtils2

Discussion in 'Tutorials & Examples' started by Erel, Jun 13, 2013.

Thread Status:
Not open for further replies.
  1. cbal03

    cbal03 Member Licensed User

    Since your ftp client can download them and your app can't.. Possibly there is a permissions issue with your server setup. The FTP server has permission to send to client but does your app have permissions in the manner that it is connecting?
     
  2. Kwame Twum

    Kwame Twum Active Member Licensed User

    Thanks guys... Erel , I found out the mime types on my server were only set to default file types. I manually included the ones that were causing issues (.apk, .amr, etc). Now my app downloads just fine. @cbal03 so set Full Control permissions... just in case ;) Thanks a lot.
     
  3. Amin Ismail

    Amin Ismail Member Licensed User

    I modified the URL in the "LargeFileDownload" program shown in your Tutorial "Download Huge Files with HttpUtils2". Everything works fine.

    Then I intentionally changed the name of download file to a non-existant file in an attempt to see what sort of error message I would get. So I get the following error message.

    ----------------------------------
    An error has occurred in sub:
    java.io.FileNotFoundException:/data/data/b4a.example/cache/1:eek:pen failed: ENOENT (No such file or directory) Continue?
    ----------------------------------

    I tried using Try-Catch at various places in the program so I could trap this error and display a more informative message but I can't seem to trap this error.

    Any suggestions on what I can do to trap it?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Check whether Job.Success = True.
     
  5. Penfound

    Penfound Active Member Licensed User

    I still can't find the file that has been downloaded. How do I download it and copy it to a specified folder?

    Please?

    Penfound
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Dim out As OutputStream = File.OpenOutput(...) 'target folder
    File.Copy2(Job.GetInputStream, out)
    out.Close
     
    Penfound likes this.
  7. Penfound

    Penfound Active Member Licensed User

    Thank you so much Erel

    Penfound
     
  8. Bart Kerver

    Bart Kerver New Member Licensed User

    I created a (huge) file uploader that basically works fine (based on the download demo, pretty straight foreward).

    In order the give feedback on the upload status (when using GSM/UTMS), I tried to create a bytes sent in some way.

    Is there a way to get the amount of bytes sent (from within the httpclient object), since for the post you only pass the HttpRequest object and the file, the rest is done automatically. The CountingStream in the demo works different since that's done by the receive.

    Or do I need to abandon the standard httpclient and work with the async and create own http protocol (hand-shake, error-code etc) for that?

    I looked into tapping into the httpclient object using the Reflector but it seems to pretty well hidden ;)

    Thanks,
    Bart
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Just pass a counting stream to HttpRequest.InitializePost.
     
  10. tucano2000

    tucano2000 Active Member Licensed User

    Erel, Some code example to Download Resume ?
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    There is no support for pausing and resuming. You can only abort the download.
     
  12. Callan

    Callan Member Licensed User

    Hi Erel,
    I'm tried the sample for this and I got this
    error on debug.

    Code:
    Parsing code.                          0.02
    Compiling code.                        
    0.36
    Compiling layouts code.                
    0.17
    Generating R 
    file.                      0.13
    Compiling debugger engine code.        Error
    javac 
    1.7.0_51
    shell\src\b4a\example\main.java:31: error: package anywheresoftware.b4a.pc.RapidSub does not exist
            anywheresoftware.b4a.pc.RapidSub.moduleToObject.put(
    "b4a.example.main""b4a.example.main");
                                            ^
    1 error
    I haven't change any codes yet just a fresh debug. If so, what extra codes are necessary to evade this issue.
    Cheers,
    Callan
    ps. I've got the updated version of http (v1.33)
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    Which version of B4A are you using?
     
  14. Callan

    Callan Member Licensed User

  15. Erel

    Erel Administrator Staff Member Licensed User

    Note that the latest version of Http library is 1.36 and it is included in the IDE.

    Seems like something is broken in your installation. The IDE probably uses an old version of DebugRapid.jar.

    Try to uninstall B4A, make sure that all the internal libraries were deleted and reinstall it.
     
  16. Callan

    Callan Member Licensed User

    I tried it with debug legacy and it works seems to be an issue with V3.8 then....I'd also like to know how will I be able to store the file it in a folder in the ext card rather than just the root...
    Here is my code
    Code:
    Sub dd_Complete(Job As HttpJob)
        
    Log("Job completed: " & Job.Success)
        
    Dim o As OutputStream
        o = 
    File.OpenOutput(File.DirDefaultExternal, "test.zip"False)
        
    File.Copy2(Job.GetInputStream, o)
        o.Close
        
    Log("Job completed: " & Job.Success)
        Job.Release
    End Sub
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    RapidSub is indeed related to the rapid debugger. You are the only one who encountered this issue. It seems like you are referencing an old version of the jar.

    The code above will copy it to a folder inside the sd card. Not the root. Check Log(File.DirDefaultExternal).
     
  18. Callan

    Callan Member Licensed User

    I will try it and let you know
    Cheers
     
  19. Callan

    Callan Member Licensed User

    Hey Erel,
    Just a quick question is it possible to download a whole subfolder?
    If not what would be the best way to do it.
    Cheers
     
  20. RickyT

    RickyT New Member Licensed User

    Hi i'm getting an error while doing job complete... This is the code
    Code:
    Sub dd_Complete(Job As HttpJob)
        
    Log("Job completed: " & Job.Success)
        
    Dim o As OutputStream
        o = 
    File.OpenOutput(File.DirDefaultExternal, "test.txt"False)
        
    File.Copy2(Job.GetInputStream, o)
        o.Close
       
    Log("Directory : " & File.DirDefaultExternal)
        
    Log("Job completed: " & Job.Success)
        
    Msgbox("Download completed","Success")
        Job.Release
    End Sub
    And this is the error code
    Code:
    java.lang.IllegalStateException: Target host must not be nullor set in parameters. scheme=null, host=nullpath=localhost/ComiX/30DaysOfNight/
    Job completed: 
    false
    Could I please get some help with this please :)
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice