Android Question google drive , httputils2, downloading xls file

le_toubib

Active Member
Licensed User
Longtime 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=[url]https://gdurl.com/xxxx[/url], 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 "
B4X:
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 ?
 

walterf25

Expert
Licensed User
Longtime 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=[url]https://gdurl.com/xxxx[/url], 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 "
B4X:
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 ?
I think you should use Job.GetInputStream, instead of Job.GetString.
 
Upvote 0

le_toubib

Active Member
Licensed User
Longtime User
thanks for ur reply
allright

i changed into this :

B4X:
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)
 
Upvote 0

le_toubib

Active Member
Licensed User
Longtime User
allright i found it
i have to close the workbook from the excel library before replacing the file otherwise it will be unreadable
 
Upvote 0
Top