Hi, if someone can help, surely @Erel I guess
I'm implementing a Server that upload a file depending of parameters
server call is that way
http://127.0.0.1:51040/getinvoice?login=pat&password=123456&factkey=smu160761.pdf
it should return binary stream of the pdf
Main is straightforward
In GetInvoice module handle
At the end, I don't know how to send the binary Output Stream
resp.ContentType="application/pdf" ???
resp.OutputStream.... ???
Help Please
I'm implementing a Server that upload a file depending of parameters
server call is that way
http://127.0.0.1:51040/getinvoice?login=pat&password=123456&factkey=smu160761.pdf
it should return binary stream of the pdf
Main is straightforward
B4X:
Sub AppStart (Args() As String)
config = File.ReadMap(File.DirApp, "config.txt")
srvr.Initialize("srvr")
srvr.Port = config.Get("PushServerPort")
srvr.AddHandler("/getinvoice", "GetInvoice", False)
srvr.Start
Log("server is listening on port: " & srvr.Port)
StartMessageLoop
End Sub
In GetInvoice module handle
B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
If req.GetParameter("login") <> Main.config.Get("PushWynbeLogin") Then
resp.SendError(500, "1") ' 1 Non authetifié
Return
End If
If req.GetParameter("password") <> Main.config.Get("PushWynbePassword") Then
resp.SendError(500, "1") ' 1 Non authetifié
Return
End If
factkey = req.GetParameter("factkey")
SMB1.Initialize("SMB1")
SMB1.SetCredentials(Main.config.Get("SMBName"),Main.config.Get("SMBPassword"),Main.config.Get("SMBDomain"))
cFile = cFact & ".pdf"
SMBPath = Main.config.Get("PushInvPath") & cTri & "/" & cYear & "/"
Dim out As OutputStream
out = File.OpenOutput(File.DirApp, "toto.pdf", False)
cout.Initialize(out)
SMB1.DownloadFile2(SMBPath,cFile,cout,True)
At the end, I don't know how to send the binary Output Stream
resp.ContentType="application/pdf" ???
resp.OutputStream.... ???
Help Please
Last edited: