I've got a B4J server set up and receiving bytes behind an API. The user must be authenticated (an auth token in the header) in order to be able to upload his files. This is working smoothly. The data is received and put in the remote secure database.
How do I then allow that data to be downloaded back to the client? What is the server-side code I need for the B4J server to send that file? I've done a search and didn't find anything about allowing a download from an authentication-required API.
Try it online: https://www.b4x.com:51042/login_example/ Note that it is not connected to the forum database. Feel free to test it and register new users. Its only purpose is to demonstrate this solution. Login Example A typical web solution consists of several folders. In this case the...
www.b4x.com
2. If the file is in the www folder then you don't need to do anything. Otherwise you need to do it with:
B4X:
Dim b() As Byte = File.ReadBytes(...)
resp.OutputStream.WriteBytes(b, 0, b.Length) 'resp is the ServletResponse object.