Write json object to file.json in assets using angular [duplicate] - json

This question already has answers here:
angular2 http.post() to local json file
(2 answers)
Closed 2 years ago.
I am using angular to create an application and has a requirement to store a json object currently stored in a variable to file.json located in src/app/assets using angular.
I have searched a lot and have not found a way to do this.
Ask if need any more information.

You cannot write files with Angular. Don't forget that the Angular app is not running in the directory structure you create. It's not even running on a server. It's running in the browser as compiled JavaScript. It has no direct write access to any filesystem.
If you need to write to server-side files in your application, you need some server-side code. This can be achieved, for example, with NodeJS (Express, NestJSā€¦) if you want to stick with JavaScript. Either way, you can't write files directly with Angular.

Related

Is it possible to specify the name of the output file in a Foundry transform? [duplicate]

This question already has answers here:
How can I have nice file names & efficient storage usage in my Foundry Magritte dataset export?
(3 answers)
Closed 6 months ago.
I have a PySpark transform in Palantir Foundry that's outputting to a csv file for export into other systems.
Currently, using the write_dataframe method the name of the file looks like this:
spark/part-00002-cfba77d5-c6ce-4b2a-ac9a-59173c7ede5a-c000.snappy.csv
is it possible to specify a filename, such as "my_export.csv" ?
It's likely easier to accomplish this using an export task rather than via a transform. Some documentation on export tasks is available here, but it is described in more detail in the in-platform docs.
If you're using a file system or SFTP export task, there is an option to rewrite paths in the task config. For example,
rewritePaths:
".*": "my_export.csv"
would rename all files to my_export.csv. I wouldn't recommend doing exactly that, as you'll have a collision if there are multiple files, but you can also capture part of the existing file name and use it to make the renamed files unique:
rewritePaths:
"^spark/(.*)": "my_export-$1.csv"

Is there any way to write to a json file in angular rather than using fs module?

I'm stuck with fs module in angular 7 cause it is showing can't find module fs when I'm trying to write to json file. Please suggest me some alternatives for this.
No, there is no way. Angular is running in a browser, on a user pc or handheld or whatever. It would be a security problem if your angular app would have access to the file system.
Google is planning this at the moment, but it's not standard.
What you can do: You can read jsons files from server via http.get request or write json to the server via http.post requests.
angular will work together with every backend server : java-spring-boot or php or node.js, ...
In node.js you will find your fs.
P.S.: the npm and node_module in your angular app only exists during development. After compiling you get plain html, js and css.

How can I interact with html file in delphi intraweb?

Hi I am currently working on delphi intraweb. I try to import html template file to the program instead of hard-code it by using components from tool palette. However, I cannot find anyway to interact with the html file satisfyingly. For example, I want to handle the values of input box in the html file or adding data to data table through delphi. Or should I perform the tasks through other aspects?
I am using IWTemplateProcessorHTML to load external html template to delphi but I couldnt figure out a way to pass values from the html file to delphi or from delphi to that html file in run-time. There is not coding involved yet.
Thanks.

synchronizing json files on device with a database

I want to synchronize data from a nosql database, have it emit json, and when there is a change and the app is online, have the app pull the changes and update them.
My react-native app uses a few language-specific json files loading them dynamically into javascript objects and then using them as my "database". One file for rendering content, one for the app texts, and one for the styles.
When the user changes the language a different directory is used with the same set of json filenames. This is done via the index.js in that directory and loaded into redux.
Must I change the way my app works, and use a NoSQL/real database directly in the app? So that I can use a solution like this one: synchronizing pouchDB with json data
(that solution is for working if I understand correctly in the exact opposite direction. The app is working with a database and synchronizing with json received from the web)
Or can I update the data in an external (preferably) NoSQL (pouchDB or couchDB) or relational database, and somehow "synchronize" it with the json files, when the app is connected to the web and have it update?
Is there a known method or framework to accomplish this with react-native?

Drop-down list from a txt file

I want to know if it is possible to create a Drop-down list in HTML using Only a txt file?
I have a list of places/countries, instead of creating for each, can i import it somehow from a txt file while each country is set in a single line?
(i know how it's done using php, i just wonder if it could be done without it)
Using pure html? No.
You will either need to use a preprocessor (sed,perl,etc) to generate the html page or a dynamic language to do it at run time - html is a static language.
You should be able to do it with javascript, but the only way I can think of involves making the txt file available on the web and using a XMLHttpRequest() to get it. There is the new file api in html5, but that is aimed at local (to the client) files.