I'm trying to use openwhisk cloud functions to leverage some existing java code. The code needs to read a local file. Is this supported in a Java Action on IBM Cloud?
Though the file is included in the jar file - the application is not able to reach the file .
OpenWhisk actions can read from the file system. Changes to the runtime filesystem are not persisted across invocations.
If you want to include a file within the JAR, you will need to need to find the location of the JAR within the filesystem, unzip it and read the file contents.
The Java runtime stores the user-provided JAR in the system-wide temporary directory as useraction.jar.
Another approach would be to store the file on an object storage service and retrieve it dynamically during invocations.
Related
I have a ApplicationData.json file which includes some data used by my application.
The file is created before the app starts (manually) and it will never be deleted.
Sometimes, I need to override it's data by recreate the file with the updated data
.
In addition, I have more files which are generated on runtime.
I want all files to be reachable outside from my application manually.
In which path should I use while read & write to them?
Where should I locate my ApplicationData.json file before the app starts using Android Studio files explorer?
I have some questions about Wildfly deployment
1.An ear, when deployed in wildfly, is extracted within standalone/tmp/vfs/deployment/ directory. Can I place a file there manually and still access it from web. (I can check it, but as of now I do not have any machine to test it).
Can I create a file and place it there via some program. The reason I am asking this question is that I need to generate some files based on user input and provide the user with a link to that file. One way to do this is to statically link a directory in JBOSS and create the file there(access it using file handlers see this). I just want to know if it can be done at all using something like VFS.
If you need to persist to a file you'd want to create a new file handler, like the link you provided describes, and write the file to that folder. You don't want to try to use that temporary deployment directory. The content is not exploded by default so writing to it would likely fail.
If you don't need to persist to a file you can just use an output stream of some sort and the user will be able to download the file.
I've looked at a number of related cases here on stackoverflow related to this, but mostly deal with the situation of deciding where to put external files and access them, which is quite clear.
In my situation, I have a Java EE application that needs to use a third party library that reads an external config file to determine the location of another file. I am using Eclipse and Tomcat.
The external config file has a line that reads like: FILENAME=[path], where path is expected to be the full path name to the file.
I have no way of knowing how they access the file, save to say that specifying /WEB-INF/classes/file or just file does not work, the library can't find it. However when I put the full name /Users/.../file on my local machine, it can find it.
As this is intended to be deployed on production server in the cloud, is my only solution to put the needed file in cloud storage, then set the config file to point to this absolute location ?
I have a .exe file, which produces certain files when made to run :
The files produced are WatchDataTest, ngrtgs.test, shubhangi, slatey (as they appear in the image)
I want to run the .exe file through a separate Java Program and obtain reference to the above files. How can this be done?
My point of view: I think, obtaining an OutputStream(wrapped by ObjectOutputStream) on the Process object of this executable can be used to read the objects (files, in this case). However, I am not sure in what way does this executable provides reference to the files produced. Other than that, I have a confusion whether the GUI display is part of the output. I mean does the OutputStream of this executable include the GUI object, which displays on the screen? If not, what all is the output of this .exe?(Pretty confusion here)
The .exe file calls your OS native functions to create those files. You cannot catch that from Java.
If you want to read the content of those files from Java, find them in the directory structure, and open them for reading with the normal Java File I/O API.
I think you want to access those certificates, right? Most likely they're not stored in separate files, but in one file called keystore. In this case I recommend to use Java PKI API or tools to manage your keystore.
I have a Java Servlet/JSP application which requires the user to upload an archive file (either .rar or .zip). This archive file is then extracted, and the extracted files are parsed. After parsing the files, the data in them is added to the database and the files are deleted again.
On my local machine, this works perfectly, since you just use the filesystem provided by the OS. But now I'd like to run this application on Heroku and I'm unsure on how to do the file uploads.
Since these files are user specific, and not permanent, my initial thoughts were that I could just use the ephemeral file system provided by Heroku and I do not require the use of S3.
At the moment, my application runs on only 1 web dyno and no worker dyno's but in the future this may get scaled to multiple web dyno's, depending on the amount of users that are going to use it.
Can I use the ephemeral file system for my specific use case, and will it scale properly?
I am currently writing using ServletFileUpload, and am writing to java.io.File; Can I just change the path of my java.io.File to a path in the ephemeral file system? What would be an example of such path?
I guess you can use the ephemeral fileystem in your specific case, as it's just a temporary usage for parsing the file.
You can use the /tmp directory but keep in mind that the file will be destroyed after the request is complete.
This is discussed in this post https://stackoverflow.com/a/12416923/476782