Android Question google drive , httputils2, downloading xls file

Discussion in 'Android Questions' started by le_toubib, Feb 12, 2015.

  1. le_toubib

    le_toubib Active Member Licensed User

    hi
    i m trying to download an excel file from a google drive using httputils2
    i used initialiseacceptall
    but still i get this :


    "Job [errormessage=, httputils2service=null, jobname=job1, main=null, mlink=https://gdurl.com/xxxx, password= , req=anywheresoftware.b4a.http.httpclientwrapper$httpurirequestwrapper@1164df5f, target=class com.mox.pb1.main, taskid=1, username=, success=true]

    job.getstring = ascii characters not intelligible

    then i use this to convert to xls "
    Code:
    File.openoutput(File.DirInternalCache,"pbtemp.xls",False)
              
    File.WriteString(File.DirInternalCache,"pbtemp.xls", Job.GetString)
            
    File.Copy(File.DirInternalCache,"pbtemp.xls",File.DirRootExternal,"pbtemp.xls")
              
    File.Copy(File.DirInternalCache,"pbtemp.xls",File.DirInternalCache,dbname)
            
    File.Delete(File.DirInternalCache,"pbtemp.xls")
    the resulting pbtemp.xls is corrupted


    does it mean the file was downloaded correctly? or the error is in conversion?

    the file is readily downloaded from android browser

    what am i doing wrong

    is there any other webdrive that s supported ?
     
  2. walterf25

    walterf25 Well-Known Member Licensed User

    I think you should use Job.GetInputStream, instead of Job.GetString.
     
  3. le_toubib

    le_toubib Active Member Licensed User

    thanks for ur reply
    allright

    i changed into this :

    Code:
    Sub JobDone (Job As HttpJob)
       
    'Load the saved image
    '   Dim tmplist As List
      ' firstime=False

    If Job.Success Then
        
    Try
            
    Dim out As OutputStream = File.OpenOutput(File.DirInternalCache,"pbtemp.xls",False)
                
    File.Copy2(Job.GetInputStream, out)
                
    File.Copy(File.DirInternalCache,"pbtemp.xls",File.DirRootExternal,"pbtemp.xls")
                
    File.Copy(File.DirInternalCache,"pbtemp.xls",File.DirInternalCache,dbname)
                
    File.Delete(File.DirInternalCache,"pbtemp.xls")

            out.Close

        
    Catch           
            
    ToastMessageShow ( "Unable to update Database",False)
        
    End Try
    Else
    Log("error: " & Job.ErrorMessage)           
    End If
    Job.Release
    End Sub

    but still the resulting file is not readable ( although same size)
     
  4. le_toubib

    le_toubib Active Member Licensed User

    allright i found it
    i have to close the workbook from the excel library before replacing the file otherwise it will be unreadable
     
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