I am new to java and trying to learn. Right now I am trying to write a download/upload manager program. I want to make a browse button for FTP so user can select from there which file to download. I can download it writing its directory, manually. Is there a way to do this using JFileChooser or with a similar class? I don't want to use a plugin since I want to write it myself. Thank you for your help.
Not sure what you mean by "I don't want to use a plugin since I want to write it myself". Unless you want to write the complete FTP Client yourself, consider using ftp4j.
JFileChooser is to choose local file(s). Or provide your own FileSystemView with ftp4j backend and use it to choose files on the remote server for download.
Short answer: Just use ftp4j to browse files over FTP.
Related
Am using Apache MINA SSHD to build my own custom SFTP Server.
I want to limit the file system my user sees. I just want them to see the directory structure under /aa/bb/cc
I do not want them to be able to see or navigate any other folder.
And from the directories under /aa/bb/cc, a user will have read access to some directories and write access to only a selected few. How do I achive this ?
The FileSystemView has been introduced for that very purpose. If you're using version 0.14.0, the following will work:
sshServer.setFileSystemFactory(new VirtualFileSystemFactory(new File("admin").getAbsolutePath()));
I have also almost got a working example here. I just have to figure out how to set the home directory dynamically.
I have made an android app and I have some .csv files with initial data. Can anyone suggest a proper way to do that? For example, someone could say "just create a folder and put them inside" but I want a better way like a setup that I can do with windows (e.g. installshield but no so advanced ).
You can make with wizard forms. In first window choose .csv file, in second window
match the fileds of .csv file with database fildes and finally upload data.
I was able to implement moving files from one directory to other in the same system using JAVA URL Connection.But I have to move files from a directory of one server to another(linux or windows) , and I should not use the third party Java APIs. Is there a way how to implement this? If yes , what configuration details are required in the program.please let me know how to implement it.
What about writing a very small script like below..
SOURCEDIR=/home/subodhr/e_books/
DESTDIR=user#server:home/subodhr/Destination/
rsync -avh --exclude="*.bak" $SOURCEDIR $DESTDIR
save this file using .sh extension
like moveFile.sh
then execute the script as ./moveFile.sh
Read the contents into serializable objects and pass them across different machines. Once received, just write them to the disk. You should be able to do this using core Java API.
Is it possible to upload a file in Play! framework only by giving a path in url?
For example I would like to call:
www.mywebsite.com/upload_PATH
It's for me quite important, because I would like to upload and process a lot of data. Selecting manually 1000 files is too much time consuming and I want to write a program which will make it for me :-) I'm using Play with Java.
If upload_PATH is a local file path on your system, it is not a good way to go.
You should write a Play action where you can upload a file, as it is done in this example.
Then, you should write a HTTP client (started by a main Java method) which go through your files and upload then calling the Play! action. You can use the httpclient Apache library for writing the client part.
As nico_ekito wrote www.mywebsite.com/upload_from_local_path won't work
In case of huge amount of files you can create temporary folder on the distant server and upload your files with FTP. Then in your app you'll need only action for post-upload processing, ie. it can check if file is valid and move it to calculated destination and register in database if required.
Other possibility is using some flash/ajax multi uploader for an example swfupload (don't know it, it's just first hit from the search engine). This approach will be better if you are going give the upload possibility to people who you don't want to give any FTP access.
Finally you can mix the solutions -> use uploader instead of FTP and later post-process new items remotely.
I'm developing a JSP application, and I want to be able to upload the contents of a directory to the server. So the user will select the directory he wants to upload, and somehow all its contents will be uploaded.
Can't be done with regular HTML/Javascript, you have to use either Java or Flash.
There is no support for this in HTML (only uploading of a single file) so there is nothing you can do in your JSP. If you want to do this in java you will have to have something client side, like a signed Applet or a jar that the user downloads and runs.
Looks like it's time for a Framework! Struts2 can handle this type of jobs well and is easy to start with. Here you can take a look at a File Upload sample.
As said, there is no way to do this in JavaScript/HTML.
If you do not want to use a Java Applet (they are clunky and your users may not have Java installed), you can let people upload a zip file and extract it on the server (there is support for this in the Java standard API). Both Windows and Mac OS allow the clients to zip a folder by right-clicking.