B4J Question Can't get an event with download2

schimanski

Well-Known Member
Licensed User
When I download a file from my server, i don't get an handler-result. I don't know, how I can read out the parameters, when I download a file such as

B4X:
Kontaktstempel.Download2(ServerPfad & "/Kontakte/Kontaktstempel.eis", Array As String("type", "download", "passwort", "1234"))
When I upload, I can check the parameter in the

B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
But it is not possible to to this after a download request...
 

derez

Expert
Licensed User
What I do (and there may be other ways) - I have an index file in my static folder, which directs to a download handler with the password entered by the user. In the handler module I check the passwod parameter.

index file:
B4X:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="index.css" />
<title>Dudu Files - login</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
</head>
<body>

<form name="input" action="http://[my duckdns]:XXXXX/download" method="get">
Password: <input type="text" name="Password" value="">
<br><br><br><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
handler:
B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
    Dim sb As StringBuilder
    sb.Initialize
    If req.GetParameter("Password") <> "YYYYYYYY" Then
        sb.Append("<br/><h1> Wrong Password ! </h1>")
        resp.Write(sb.ToString)
        Return
    End If
 
Top