Hello.
Again I met another problem that I can not understand.
I press LABEL on the page and should send the specified file to the user. Everything is fine and the file is right in the PC browser, but when doing the same thing on the mobile browser (Android) it's getting messy.
Sub for click label:
In Main is:
Handler 'send':
Error for mobile:
What could be the reason?
Again I met another problem that I can not understand.
I press LABEL on the page and should send the specified file to the user. Everything is fine and the file is right in the PC browser, but when doing the same thing on the mobile browser (Android) it's getting messy.
Sub for click label:
B4X:
Sub zal1_Clicked(Target As String)
Dim lista As List
Dim zal As ABMLabel = page.Component("zal1")
lista = DBM.SQLSelect(DBM.GetSQL, "select file1, orginal_file1 from message where idx=?", Array As String(zal.Tag))
Dim m As Map = lista.Get(0)
Dim link As String = "../../send?file1="&m.Get("file1")&"&file2="&m.Get("orginal_file1")
ABMShared.NavigateToPage (ws, "", link)
'Log (folder & FileName)
End Sub
B4X:
'----------------------START MODIFICATION 4.00-------------------------------
Public Sub NavigateToPage(ws As WebSocket, PageId As String, TargetUrl As String) 'ignore
Dim testTargetUrl As String = TargetUrl
If Not(testTargetUrl.EndsWith(".htm") Or testTargetUrl.EndsWith(".html") Or testTargetUrl.EndsWith("/")) Then
TargetUrl = TargetUrl & "/"
End If
If PageId.Length > 0 Then ABM.RemoveMeFromCache(CachedPages, PageId)
If ws.Open Then
' it doesn't keep navigation history in the browser (the back button exists the application)
'ws.Eval("window.location.replace(arguments[0])", Array As Object(TargetUrl))
' if you need browser history just comment the lines above and uncomment the lines below
' it keeps the navigation history in the browser
ws.Eval("window.location = arguments[0]", Array As Object(TargetUrl))
ws.Flush
'ws.Close ' ALSO NEW 4.00
End If
End Sub
'----------------------END MODIFICATION 4.00-------------------------------
In Main is:
B4X:
srvr.AddHandler("/send", "send", True)
Handler 'send':
B4X:
Sub Class_Globals
End Sub
Public Sub Initialize
End Sub
Sub Handle (req As ServletRequest , resp As ServletResponse)
Dim FileName As String = req.GetParameter("file1")
Dim FileName2 As String = req.GetParameter("file2")
Dim Folder As String = File.DirApp & "\www\" & ABMShared.AppName & "\uploads\"
If File.Exists (Folder, FileName) = True Then
Dim In As InputStream = File.OpenInput (Folder, FileName)
resp.SetHeader ( "Content-Type", "application/xxx")
resp.SetHeader ( "Content-disposition", "filename="""&FileName2&"""")
File.Copy2 (In, resp.OutputStream)
Else
End If
End Sub
Error for mobile:
B4X:
Error occurred on line: 19
org.eclipse.jetty.io.EofException
at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:292)
at org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:429)
at org.eclipse.jetty.io.WriteFlusher.completeWrite(WriteFlusher.java:384)
at org.eclipse.jetty.io.ChannelEndPoint$3.run(ChannelEndPoint.java:139)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Istniejące połączenie zostało gwałtownie zamknięte przez zdalnego hosta
at sun.nio.ch.SocketDispatcher.writev0(Native Method)
at sun.nio.ch.SocketDispatcher.writev(SocketDispatcher.java:55)
at sun.nio.ch.IOUtil.write(IOUtil.java:148)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:504)
at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:272)
... 10 more
What could be the reason?