How with the WebServer do I get my servlet to return a file please?
I noticed from an error msg that it is based on Jetty, would documentation from that project help, or is the implementation different?
Thanks,
Paul
I can see no way of setting response headers in a servlet and even if you manage to set content-type to something like application/octet-stream, SetResponse is likely to choke on binary data.
It probably is not worth trying to persuade your attendees to download an app that uses xmlhttprequest to download the files as they won't all be using Android.
Your server could offer to email the resources to the attendees but without session cookies they would need to enter their address for each download.
If the resources are text you could just return them as the response and ask the attendees to copy/Paste them from their browser. Simple for some people but not everyone.
Same goes for asking them to LongTouch/right-click links.
Sorry. A response of this length should be more helpful than this. I have just put down my musings in case they trigger any more sensible ideas in you or someone else.
Its all achieved through their device's browser, that's the simplicity.
They don't need the app. Just the presenter does.
Browsers are just pointed on shared network to app's device IP and app's sever's port.
I'm past proof of concept phase.
No worries, just hoped DroidScript webserver had the ability to serve files from script, can achieve desired result in a combo way using php's built in server.
Thanks,
Paul
For reading things like PDF files off disk does app.ReadFile() have any additional encoding options as well as Encoding-options: windows-1252?
Otherwise I think I won't be able to get non-text files like .pdf or .7z etc in for btoa() or http://phpjs.org/functions/base64_encode/ to work with.
Paul
Here is the info, with examples:
http://wiki.droidscript.me.uk/doku.php?id=sample_code:random_file_acces
The regexes expect a pure hex string with (possibly) \r and \n to be removed.
What ReadData is returning is a comma-separated string of hex values.
Removing the commas will not be enough as the (2 digit) values do not have a leading zeroes.
It should be reasonably easy to do in a loop but whether this is getting to be too much work is a question.
If you need help building the loop I'm happy to write one for you but I suspect it's well within your abilities.
I'll have a look at that when I next can.
Down here in the antipodes we're 12 hours ahead, so sorry for the dealay in answering.
Paul
Unfortunately, passing chunks to btoa is probably not going to result in base64 chunks you can just concatenate together, though if you choose the chunksize carefully, it may not be impossible to work around.
Whilst this is an interesting project, you want to use it in the real world. By now I would be looking back to plan BB or on to C etc.
The php server plan looks viable.
Alternatively, perhaps you can use a purely jetty approach if you are able to store base64 versions of your resources on the sdisks.
Persevered with this seeing a much wider general usefulness for it in DroidScript.
On the same general theme, can we take our binary hex version through to making a blob that html5 can work with?
For security reasons, I assume we are blocked out from directly loading from sdcard the files needed for the underlying browser engine - e.g. for FileReader
https://developer.mozilla.org/en-US/docs/Web/API/FileReader
... there's a tremendous amount - already built right in (not just base64!) - we can do if we can get properly formed binary blobs acceptible to the browser engine!
Paul