JAVA: multiple files download at the same time? - java

Is there any methods for downloading multiple files at the same time? That is, after select multiple files, click the download button, and choose the destination directory, the files selected will be downloaded at the same time.
i googled it and not find any solutions, can anybody know? im using struts1 and spring2.

This is not part of the normal file download model supported by web browsers. You might be able to do this with some client-side Javascript. However, I suspect it is not possible, since Javascript driven upload of multiple files would probably entail breaking Javascript's security sandbox.

Don't think so. You can download a zip though.

Related

Replace Applet in downloading and executing a file

I have an application that has an applet that does two simple things:
Download an executable jar file from our server (if the user doesn't already have it) to an specific folder in the user's PC
Execute the jar file with the corresponding parameters
This jar file monitors an Office file for changes and send it back to our server.
The problem is the war Chrome is creating with Java with this NPAPI thing. So I have until September to think of an alternate technology or stop the Chrome support.
Do you think of some other way to achieve the same result? Just download and execute. Doesn't seem that hard =(. Can HTML 5 do that?
EDIT
I was looking into Java Web Start and became a little happy. It appears that it can do what I want: executing a up to date jar file passing parameters. But I never worked with JWS, so I have some doubts:
Is it possible to pass parameters to it? I read about some JSP files that you can configure to do that, but I'm still unsure.
Theoretically, it should start automatically from a browser link, am I right? I tried this site:
https://docs.oracle.com/javase/tutorial/deployment/webstart/running.html
and it didn't work that way. I had to mark "always open files of that type" on Google Chrome. Is there a way for automatize it?
Thanks again!!
From what I know there are at least two things that allow you to stick with Java.
Webstart
Install4
Webstart is provided by Oracle and allows you to download Java program from the web and execute them. Update mechanisms exist, so you can always provide a current version.
Install4J (or any other installer for Java applications that offers an update mechanism) provides an installer which enables your customer to install an application which afterwards will be kept up to date by the integrated update mechanism. But Install4J comes at a price, there might be freeware / open source alternatives. Install4J and its alternatives are often discussed here on SO, you might want to check here.
I think the FileAPI of HTML5 is limited and can not access arbitrary files because a sandbox prevents this. You might check SO again for details about that.

Uploading the contents of a directory in JSP

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.

Is there any way to download Mediafire links?

I'm writing a program that reads in a text file of artists and albums, and spits out Mediafire download links.
I want to take it a step further and actually have it download those links, but I don't know if there's a way to do that.
You may want to look at JDownloader - it's an open source Java application that can download from many hosts, including Mediafire (I believe). You could either use it to download the links, or borrow their Mediafire code (assuming it is compatible with the licensing on your own application).

Upload large files with browsers without having it hanging (preferably with flash)

I am trying to upload a lot of files from a browser to a webserver that I have total control of. I've tried to use SWFUpload, but the problem is that my browser hangs when I am uploading a file. The files are supposed to be of any length (up to 2GB due to other restrictions, of course).
While the upload is in progress the browser hangs and the GUI is not updated. When the file is finally uploaded the GUI responds again. In firefox the entire browser stalls and in Chrome just the tab.
I thought it might have something to do with flash trying to inject the entire file in to the memory first, but that does not seem to be the case (although different test cases yielded different results, but I'm not sure that it's because of that reason).
An applet is also an option, although flash is preferred. The reason I don't want to use a form is because you can select multiple in flash (also possible with Java, I assume) which is a nice feature that I'm going for.
Any ideas? Thought?
(math|tob)ias
If you're using linux, this is a known problem. For Windows users this doesn't happen. Otherwise, you'll have to stick to ajax (the best way is with the jQuery forms plugin).
http://www.plupload.com/, this one looks interesting, but I haven't looked into it. You may want to give it a try.
Try an AJAX one:
http://sourceforge.net/projects/uber-uploader/
Lighter on the resources and more platform-independent.
client-side I like this jquery plugin:
http://valums.com/ajax-upload/
if you need examples of server-side handling:
http://php.net/manual/en/features.file-upload.php
I've use this for my projects... http://jupload.sourceforge.net/ I found I had better results though when I used it in FTP mode. I had issues with http uploads. It does support multiple files which is nice. You can upload the files into an "incoming directory" and then process them later when the transfer is finished.
Check SWFUpload swfupload.org
and there is a descussion about this point:
http://swfupload.org/forum/generaldiscussion/173

Best way to upload multiple files from a browser

I'm working on a web application. There is one place where the user can upload files with the HTTP protocol. There is a choice between the classic HTML file upload control and a Java applet to upload the files.
The classic HTML file upload isn't great because you can only select one file at a time, and it's quite hard to get any progress indication during the actual upload (I finally got it using a timer refreshing a progress indicator with data fetched from the server via an AJAX call). The advantage: it's always working.
With the Java applet I can do more things: select multiple files at once (even a folder), compress the files, get a real progress bar, drag'n'drop files on the applet, etc...
BUT there are a few drawbacks:
it's a nightmare to get it to work properly on Mac Safari and Mac Firefox (Thanks Liveconnect)
the UI isn't exactly the native UI and some people notice that
the applet isn't as responsive as it should (could be my fault, but everything looks ok to me)
there are bugs in the Java UrlConnection class with HTTPS, so I use the Apache common HTTP client to do the actual HTTP upload. It's quite big a package and slows down the download of the .jar file
the Apache common HTTP client has sometimes trouble going through proxies
the Java runtime is quite big
I've been maintaining this Java applet for a while but now I'm fed up with all the drawbacks, and considering writing/buying a completely new component to upload theses files.
Question
If you had the following requirements:
upload multiple files easily from a browser, through HTTP or HTTPS
compress the files to reduce the upload time
upload should work on any platform, with native UI
must be able to upload huge files, up to 2gb at least
you have carte blanche on the technology
What technology/compontent would you use?
Edit :
Drag'n'Drop of files on the component would be a great plus.
It looks like there are a lot of issues related to bugs with the Flash Player (swfupload known issues). Proper Mac support and upload through proxies with authentication are options I can not do without. This would probably rule out all Flash-based options :-( .
I rule out all HTML/Javascript-only options because you can't select more than one file at a time with the classic HTML control. It's a pain to click n-times the "browse" button when you want to select multiple files in a folder.
I implemented something very recently in Silverlight.
Basically uses HttpWebRequest to send a chunk of data to a GenericHandler.
On the first post, 4KB of data is sent. On the 2nd chunk, I send another 4K chunk.
When the 2nd chunk is received, I calculate the round trip it took between first and 2nd chunk and so now
the 3rd chunk when sent will know to increase speed.
Using this method I can upload files of ANY size and I can resume.
Each post I send along this info:
[PARAMETERS]
[FILEDATA]
Here, parameters contain the following:
[Chunk #]
[Filename]
[Session ID]
After each chunk is received, I send a response back to my Silverlight saying how fast it took so that it can now send a larger
chunk.
Hard to put my explaination without code but that's basically how I did it.
At some point I will put together a quick writeup on how I did this.
I've never used it with files of 2GB in size, but the YUI File Uploader worked pretty well on a previous project. You may also be interested in this jQuery Plugin.
That said, I still think the Java Applet is the way to go. I think you'll end up with less portability and UI issues than you expect and Drag/Drop works great. For the record, Box.net uses a Java Applet for their multi-file quick uploads.
OK this is my take on this
I did some testing with swfupload, and I have my previous experience with Java, and my conclusion is that whatever technology is used there is no perfect solution to do uploads on the browser : you'll always end up with bugs when uploading huge files, going through proxies, with ssl, etc...
BUT :
a flash uploader (a la swfupload) is really lightweight, doesn't need authorization from the user and has a native interface which is REALLY cool, me thinks
a java uploader needs authorization but you can do whatever you want with the files selected by the user (aka compression if needed), and drag and drop works well. Be prepared for some epic bugs debuggin' though.
I didn't get a change to play with Silverlight as long as I'd like maybe that's the real answer, though the technology is still quite young so ... I'll edit this post if I get a chance to fiddle a bit with Silverlight
Thanks for all the answers !!
There are a number of free flash components that exist with nice multiple file upload capability. They make use of ActionScripts FileReference class with a PHP (or whatever) receiver on the server side. Some have recently broken with the launch of FP10 but I know for certain that swfupload will work :)
Hope this helps!
What about these two
Jupload
http://jupload.sourceforge.net/
and
jumploader
http://jumploader.com/
Both are java applets but they are also both really easy to use and implement.
what about google gears?
There are HTTP/HTTPS upload controls that allow multi-file upload. Here is one from Telerik, which I have found to be solid and reliable. The latest version looks to have most if not all of your feature requirements.
You can upload multiple files with HTTP forms as well, as Dave already pointed out, but if you're set on using something beyond what HTTP and Javascript offers I would heavily consider Flash. There are even some pre-existing solutions for it such as MultiPowUpload and it offers many of the features you're looking for. It's also easier to obtain progress information using a Flash client than with AJAX calls from Javascript since you have a little more flexibility.
You may check the Apache Commons FileUpload package. It allows you to upload multiple files, monitor the progress of the upload, and more. You can find more information here:
http://commons.apache.org/fileupload/
http://commons.apache.org/fileupload/using.html
Good luck

Categories

Resources