Hello community,
I'm having trouble acquiring an image saved as a blob.
I am using a b4j app on desktop which acts as a server where a b4a app acquires data from the SqlLite database located on the local server.
I can successfully save the blob image on the db with the b4bj app.
Then I request through jobdone the image saved on the db, the problem is that the image I am going to save on the android device is 0kb.
This is the code:
CODE:
Sub JobDone(j As HttpJob)
If j.Success Then
If j.JobName = "send object" Then
Log(j.GetString)
Else If j.JobName = "send_Function " Then
Log(j.GetString)
Else If j.JobName ="Share_Icon" Then
Log("Icona: "&j.GetString)
Dim out As OutputStream = File.OpenOutput(File.DirDefaultExternal, "img.jpg", False)
Dim icon As Bitmap
File.Copy2(j.GetInputStream,out)
out.Close
End If
j.Release
ProgressDialogHide
End Sub
File.DirInternal should be the default location for most files.
Note that you should avoid using File.DirDefaultExternal and use RuntimePermissions.GetSafeDirDefaultExternal instead (read about it in the runtime permissions tutorial).
Many things have changed in B4X and also in the underlying platforms. I will try to list here all kinds of (old) features that have better alternatives. B4X is backward compatible so these features still work. The recommendations are more relevant for new projects or when implementing new...
Hi Don Manfred thanks for the advice however I tried to follow your advice but I still get a 0kb image.
I opened the sqllite db and exported the image and it works in the cell there is a 7.99 kib blob.
I am using this handle to retrieve the image in b4a.
code:
Sub Class_Globals
Private fx As JFX
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
End Sub
Public Sub Handle(req As ServletRequest, resp As ServletResponse)
Dim lista As List
lista.Initialize
Dim i As Int=0
lista.Add(DBUtils.ExecuteList(Main.SQL1, "SELECT Icon FROM TabPulsanti", Null,0,lista))
For i=0 To lista.Size-1
resp.Write(lista.Get(i))
Next
End Sub