I'm guessing from reading the forum, there is no way to create a file and save it to the client's pc using system.perspective.download.
I have a page that allows the user to set a bunch of settings and I was hoping the user could click an export button to save a json file locally. Is the only way to do this to use vision?
I was thinking I could maybe open a browser and dump the json into that so they could copy/paste the text but that's a bit wonky.
Anyone have any tips or suggestions? Thanks
system.perspective.download()
causes the browser to open a save file dialog if the user has configured their browser to always ask for where to save.
Teach you users to set their browsers that way. Or use Vision.
Thanks, I have my browser (firefox) to ask where to save the file. I get prompted but when I select a folder nothing gets downloaded. I tried chrome and edge and got the same thing.
I don't see any errors or warnings from the browser. im just putting my json variable into the function, do I need to convert he json to bytes or anything?
Thanks!
We will need to see your script to help you out...
JSON isn't one of the supported types for the data
argument, so yes:
system.perspective.download()
You probably want to run your json dictionary through system.util.jsonEncode()
1 Like
Its a simple script, thanks!
data = {'name':{1:1,2:1,etc...}}
system.perspective.download('download_me.json', data)
Awesome, thank you! I didn't know there were unsupported types, I was assuming it would come across as a string but I didn't print the type to find out.
It worked, thank you!
2 Likes