I search how to write a file with angularjs, after get it in json. I have already the json file in my folder, but with onclick, users can manually update it with the new content and overwrite the same file. How to write it ? (i don't ask the get distant file part).
I need locastorage functions ? it's for android application, so which storage i must use ?
You can't write files with javascript. You would need to pass the data to PHP or nodejs (aka a server side language) that has access to your filesystem. Javascript is client facing, so it doesn't know anything about the filesystem on the server it is running.
Related
I am trying to load Tensorflow.js model via HTTP protocol. Tensorflow.js requires me to store 'model.json' and 'weights.bin' files in the same folder. But I can only call 'model.json' as a parameter. It refers to the binary file by itself. That is how it works as far as I know.
For now, in the local environment, I am loading the model from the localhost(Http://127.0.0.1:8080) and it works fine.
However, the actual application accepts HTTPS protocol only. So I have tried to store them with models and weights in the same buckets in S3 and called via Lambda but it seems like only 'model.json' is retrieved. I am thinking of using EC2 instances where the Python Flask server is running but it seems like the same that only model.json is retrieved, not binary files.
Is there any way that I can retrieve 'model.json' with referring to the weight file? Is there anyway to host file server remotely with HTTPS protocol?
TFJS downloads model JSON, parses it and uses whatever paths are specified in the JSON - you can edit that file and set any URL you want for weights.
Alternatively, you can also use lower-level methods to load weights manually (in case you want to have a custom loader, etc.), but leave that for future until you're more comfortable with TFJS.
I have created properties file in other directory of my computer. I want to read the data from that file and display it. So can anyone please suggest me, How can I achieve this.Thanks in advance.
From what i understand, you have a properties file on YOUR computer and you want to read that file from reactjs app. This is not possible as front end is not allowed to directly access user's hard disk. This would be a big security flaw. This is because the front end part runs on the client side.
Consider a situation where you have written code to read file from desktop. Then your app would be able to read the desktop files of ALL USERS who use that app. That's why you always see an upload button when you have to choose a file to read. The file is first sent to server side and then processed.
Since reactjs runs on client side, it is better to maintain a server and make an API call to it to fetch the data. Or you can hard code it in react app itself if it isn't sensitive info.
On front-end side - You can't and You should not be able to because it'd be a huge security risk. Do not try to solve it on the client side. Try to think about a back-end solution after uploading that particular file to the server.
On the other hand - why are you trying to keep a file, which is logically connected with the app - outside of the repository ?
Since its not clear what you are trying to achive,
Situation 1. You developed a react app for users, which is trying to read a user's file on his computer.
This is not possible as reactjs is a front-end library which can access the resources limited to browser only. You just can't read someone else's files.
Situation 2. The file is a part of you project which is in different directory.
So just put your file inside the your project directory, and since it is a properties file then this is how you can import it inside your project.
Is it possible to send a http upload request a file to a Apache or IIS that will have a fileName with "../" or ".." that wouldn't be rejected and would be passed to php or ASP.Net engine?
Not really the way you are asking. By the time it gets to the server the browser has read the file and delivered it as a chunk of content with no information about where it came from other than the original file name which you can choose to use or discard.
Generally file uploads go into a temporary storage place (e.g. /tmp) and then need to be moved out of there to somewhere which you can control and name.
This storage is configured on the server, and so any attempt to put path info into the filename should also be blocked by the file upload implementation of the server which should sanitise the filenames again if the browser didn't already do so.
If there's a bug then all bets are off though.
I am using Java, GWT and Eclipse. I have a static XML file I want to parse to get certain data that will fill in list boxes and other info. How can I read the static XML file in both the server and client side of the code? Where do I put the XML file? Also, where can I put it if I only want the server to have access to it (since it contains sensitive data)?
If you need it on a server side only, put it in the /war/WEB-INF directory, and you can read it directly in your server code.
You can use a DataResource if you need a file on the client side:
https://developers.google.com/web-toolkit/doc/latest/DevGuideClientBundle#DataResource
If you want this file accessible on the client side, put it in the /war directory.
I would suggest that you parse the file server-side using any good XML parser (for an example see this tutorial) and put the resulting data in POJOs. For the data that you need client-side, you can make an RPC call to the server to retrieve the POJOs previously populated. A good place to put the XML file to prevent it from being directly accessible is under the WEB-INF directory of your webapp.
I have a ~2MB file that my Google AppEngine server must use (not serve) as part of a computation for a service request.
That is, a client makes a particular request, my GAE server must first get the data from this ~2MB file, do some computations using this data, then serve a small response back to the client.
Where best do I store this data so that it can be quickly read and used by the server in the computation?
If the following assumptions hold true
the file is not going to require updates outside of appengine code updates
that the file is read only
Then deploy the file with your code and read the file into memory during startup (ideally using warmup requests) and just operate on it from memory. If you code has to have file based semantics to access the data (read,seek, etc) then read the file contents and wrap it in StringIO.
You will need to assign the value read from the file to a module level variable, that way whenever you get a new request you can just get the files contents by importing the module and referencing the name. ie. mymodule.filecontents