Hi guys, How would I simply download data from within an app? (For arguments sake a BIN file or a DAT file, but one with a full range of ascii values).
In this specific case, the data is created real-time by the app run in chrome on a desktop and is largely a processed extract from volt. Pls note that although the app is volt hosted, I don’t consider it a volt question as I’m interested to know how one does it even without volt.
If it sounds like a daft question that is covered elsewhere, forgive me but as soon as google “nsbasic download” you can imagine I am flooded with down topics from trials to adverts…
It’s actually a very good question. AppStudio runs inside the browser’s sandbox, which prevents web apps from reading or writing your computer’s filesystem. (If you think about it, you really don’t want random web pages to be able to do this!)
Tell us a bit more about how you want to use the data.
Hi thanks, our msgs just crossed. Agreed about the security issues. My client just needs a file that he would then re-process into charts. The data is just logs, but does contain odd chars like SOH, TAB, VTAB, CR. What I envisage is the client clicking a button saying (eg) “download extract”. For me, this is only needed for a Windows / Chrome environment. Cheers
I should have said I’ve reviewed Dropbox and GDrive & they are too complex. My client won’t set up a GDrive or fiddle around with dropbox every time. …
What I was hoping for is an ability to add in a bit of HTML somewhere (I don’t know how as yet) that furnishes a link, and I just return maybe all the contents of my volt, an extract saved internally as a string or as an object, etc, and the browser facilitates the download as normal.
Can you confirm no such thing is possible within reason? Thanks
Here is a tested sample from that link working in NSB…
Function button_onclick()
JavaScript
var data = [["name1", "city1", "some other info"], ["name2", "city2", "more info"]];
var csvContent = "data:text/csv;charset=utf-8,";
var dataString;
data.forEach(function(infoArray, index){
dataString = infoArray.join(",");
csvContent += index < data.length ? dataString+ "\n" : dataString;
});
//'use JavaScript's window.open and encodeURI functions to download the CSV file
var encodedUri = encodeURI(csvContent);
window.open(encodedUri);
End JavaScript
End Function
…Instant download in chrome (desktop) when you click the button. (Does nothing in a phone tho’).
Update: This limits to 2097152 bytes (2^21) of encoded length. Larger gives “network error”.