Hi, All
I use my PHP-script that gives me a binary file:
Headers show correct file size:
But result File.Size after copying it from Job - smaller a bit, so - corrupted.
If to make this downloading by a Chrome browser - the file is downloaded fully OK, and opened OK - for sure not corrupted.
How to understand it ?
I use my PHP-script that gives me a binary file:
B4X:
Sub Download_Update(u As String)
Dim j2 As HttpJob
j2.Initialize("", Me)
j2.Download(u)
Wait For (j2) JobDone(j2 As HttpJob)
Dim Allow As Int
If j2.Success Then
'Log(j2.GetString)
If j2.GetString = "Wrong password !" Then
j2.Release
ToastMessageShow(j2.GetString, True)
CallSubDelayed(Me, "Activity_Resume")
Return
End If
Log(j2.Response.GetHeaders) 'HERE CORRECT FILE SIZE !
Allow = 1
Starter.SQL.Close
File.Delete(others.Folder, Starter.dbName)
Dim out As OutputStream = File.OpenOutput(others.Folder, Starter.dbName, False)
Wait For (File.Copy2Async(j2.GetInputStream, out)) Complete (Success As Boolean)
Log("Success: " & Success)
If Success Then
Log(File.Size(others.Folder, Starter.dbName)) 'HERE SMALLER SIZE THAN MUST BE
Allow = 1
StopService(Starter)
Sleep(10)
StartService(Starter)
Sleep(10)
Else
Allow = 2 'error
End If
Else
Allow = 2 'error
End If
If Allow = 0 Then
Msgbox("No update", "Нет:")
Else If Allow = 1 Then
Msgbox("Updated OK !", "ОК:")
Else
Msgbox("Update error.", "Try later:")
End If
j2.Release
Activity.Finish
End Sub
Headers show correct file size:
B4X:
(MyMap) {connection=[keep-alive], content-description=[File Transfer], content-disposition=[attachment; filename=db.sqlite], content-length=[1134592], content-transfer-encoding=[binary], content-type=[application/x-sqlite3], date=[Thu, 23 Jun 2022 15:18:49 GMT], server=[nginx/1.23.0]}
But result File.Size after copying it from Job - smaller a bit, so - corrupted.
If to make this downloading by a Chrome browser - the file is downloaded fully OK, and opened OK - for sure not corrupted.
How to understand it ?