Select to view content in your preferred language

create a .json file on the fly and store it at the widget level

2020
7
Jump to solution
08-11-2016 06:51 AM
Alexwang
Frequent Contributor

Hello, is there a way within WAB to create a .json file on the fly and save it at the widget level? The .json will be used to store graphics for users and can be updated with time. thanks!

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Alex,

No. Allowing client side code like JS to write to the file system without a user click and to a specific location would be a huge security risk. You can write a file and download it in most browsers (like you can see in the eDraw widget)  but that you not be the same as what you are wanting.

View solution in original post

7 Replies
RobertScheitlin__GISP
MVP Emeritus

Alex,

No. Allowing client side code like JS to write to the file system without a user click and to a specific location would be a huge security risk. You can write a file and download it in most browsers (like you can see in the eDraw widget)  but that you not be the same as what you are wanting.

Alexwang
Frequent Contributor

thanks Robert for your response. Does dojo or javascript allow to write to an existing .json file on the web application? I looked at the dojo/request/xhr but haven't test it yet.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

  No this would be he same type of huge security hole for hackers to use if it was available. Your option for saving things on the client side is to use local storage (HTML 5 supporting browsers) or Browser Cookies. The Bookmark widget uses local storage.

0 Kudos
Alexwang
Frequent Contributor

Thanks Robert. Local storage won't work for my scenario since I need to share the .json with all users using the widget. is it possible to call a GP service to create the file on the fly, pass the data, and write the data in the file?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

  I am not a GP person, but the way I would tackle this workflow is to develop a .Net web service that would be used to write info to a database hosted on your servers that the widget would communicate to using RESTful web service to read and write info or even easier would be to make a editable FeatureService table that stores the data and have the widget query the table and/or write new rows to it.

0 Kudos
Alexwang
Frequent Contributor

Thanks Robert. .Net service is not area of  my expertise. I am still thinking the GP service option. So a GP service takes a json input and the underling python script is going to save the json string into the .json file. This way there won't be any editable FeatureService involved. Possible?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

Like I said I am not a GP guy so I don't know.

0 Kudos