I want to download multiple files (file is in zip format) from server to client machine specific path within unzip format. How can I achieve this?
If the server exposes these files as an HTTP resource, any HTTP client program (such as wget, cURL, browsers and others) would be able to retrieve them. If the resources are exposed in another fashion, you'll need to use an appropriate client for that (e.g. SMB shares you can mount the resource using Explorer or SAMBA; FTP you can use an FTP client; etc.).
To download multiple files, unless you're talking about thousands, you can simply invoke the client once for each file. If you want this to be done programatically (e.g. as part of a build), this can be done with a shell script (batch script in windows) or as part of some higher-level construct, e.g. an Ant script if it's part of a Java-based project's build.
If your problem is that the server isn't currently making the files available, you'll need to make your question more specific to clarify this.
Related
I've used Commons IO to write a program that copy files and other things. But I want to copy a file to a local ip address \\10.x.x.x, but the user doesn't have rights to do the copy, so I need to put an ID and password to access it. However I cannot find a way I can do that.
To move file I use :
FileUtils.moveFileToDirectory(fichier, destDir,true);
But my directory is something like \\10.x.x.x\files and only a few users can write in that directory so I have an ID & password that let you move files there. I want that even if the users don't have rights to move files to that directory my program can do it.
It is not really the way Windows security works. If you really want to do it that way, you will have to use Java Native Interface or Java Native Access, and manage to call the WNetAddConnection function from Mpr.dll (and do not forget to call WNetCancelConnection when done).
But you would have to store a password in your program, which is poor security practice.
The standard way to do that would be to start a service that would run under a user that has access to the desired directory, and have your program to communicate with it using whatever you want, the simplest way being probably TCP/IP. But unless you have special requirement for that I would not recommend to use Jave for those kinds of program.
A more Java alternative would be to start a Tomcat service on server machine running under a user having access to the directory. That way you just have to develop a standard Java Web Application able to upload files that would save the files to the proper directory. But it would be a traditionnal and portable Java application with no need for JNI nor JNA.
If cannot use a Tomcat and do not want to invest to much on it, you could split the program in pieces :
one client program that copies files on a directory (on server machine) with File creation rights for everybody - can decays to the copy utility if nothing more has to be done or can easily written in Java
one server program that will run on server machine under a user that has full write permissions on target directory. This one can also be easily written in Java
you can easily install the server program as a service on the server machine with sc and srvany according to this answer on ServerFault
If you use a client program, you could easily add a digital signature file with each copied file, but as I said above, it is poor security practice and add little if any security. At least the program should be executable and not readable, and the sources should be kept hidden. It is better to log the users that copied the file and ask them what happened is you find a problem.
I have a web application built on the JVM. In this application the users are able to upload files. I read the contents of the file and do "something" with it.
In addition to this, I would like to give option to the users to put in a directory path. This directory path will be read by the application and the directory will be scanned for all relevant files (.CSV). And each will be processed.
Questions
Will the web-application be able to scan the directory located on the users machine? Or the directory path need to be in a network to which the web-app has access to?
I will be using the Commons IO package to scan the directory for files and process the files, is there a better approach?
You cannot access file system of user machine from pure web application. This task can be implemented using trusted applet or java application executed via java web start or trusted flash component or other native component (browser plugin).
Applets are almost obsolete and require JVM on client side. Java web start still requires JVM. All signed components (java based, flash, native code) require user approval.
I think that better and more modern way is to use a great feature of HTML 5 that allows not navigation to specific location on disk (that was possible since HTML 1.0) but also selecting a full directory.
Take a look on the following discussion for details: Does HTML5 allow drag-drop upload of folders or a folder tree?
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
I have a java instalation package (jars with necessary support files in local system) , is it possible to call a function(in java installtion package) from html ? or any other supporting technologies
eg: in my local system, i will have (C:\myapp\lib\test.jar), i need to make a call to a method in the jar from html .
which technology can be used to enable this .
A web app(servlet container) will be used to generate the html code
Q: Do you want to run your .jar client side (as an applet), or server side (as a servlet)?
It sounds like you want to execute an Applet on the client's PC. It also sounds like you want to read and write to the user's filesystem, which requires special privileges.
Here is a good article on creating a "trusted applet":
http://www.developer.com/java/other/article.php/3303561/Creating-a-Trusted-Applet-with-Local-File-System-Access-Rights.htm
See also:
http://docs.oracle.com/javase/6/docs/technotes/guides/security/spec/security-spec.doc1.html
http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/plugin.html
*
Well at school we are not allowed to run .exe's (YES WE have windows... omg why, also you can't save DLL files) so when I needed an FTP server I just download a Java FTP Server named FTP-GO. We can run jar files, but only by double clicking on them, so we cannot provide any parameters. What I want now is a web server in a jar file which also supports PHP scripts, the disk limit I have is 100mb, of which I am using 25mb (but I can run jars from an USB stick). so if there is any equivalent to http://www.jibble.org/jibblewebserver.php which also supports PHP, which one would you recommend?
Maybe Quercus or Der Herberlin Bremsserver.