Zipping multiple files on server side and then Downloading them - java

I have a requirement to download multiple files from server and zip them into one file. So that user will have to deal with only one file while downloading.
I need in Java/JSP code or Javascript

It's very easy.
First, allow the user to choose files (if the application requires them to do so).
Then on clicking download create a zipped file dynamically and add all chosen files. Allow the user to download this file.
I'd used Zip functions in PHP for similar functionality in the past.
You can refer Compressing and Decompressing data using Java APIs from Sun Developers Network (SDN) on Oracle website.

Related

get uploaded file path in java web application

Since from the 4 days i have been trying to find out the path for the uploaded file. I think it wont possible. Can any one tell me how to get the uploaded file path in java web application. Is there any external API to get the uploaded file path? And my project is google app engine type project. Please some one answer it.
As you can't write to the file system it's likely you can't do whatever it is you are trying to do. So you need to use one of the storage options available instead, likely GCS.
https://developers.google.com/appengine/docs/java/googlecloudstorageclient/
Google Cloud Storage is useful for storing and serving large files.
Additionally, Cloud Storage offers the use of access control lists
(ACLs), and the ability to resume upload operations if they're
interrupted, and many other features. (The GCS client library makes
use of this resume capability automatically for your app, providing
you with a robust way to stream data into GCS.)

Dynamically generating files and providing those files for download in Google App engine

I am creating a web app in google app engine using java which dynamically generate an HTML file. The requirement is such that if the Html file size increases from a certain limit (say 3 mb), then it should be split into two files and zipped together and that zip file should be sent back as the response.
I would like help on how and where to create those temporary HTML files and then zip it, in google app engine as i guess GAE doesnt allow to write on the filesystem.
Please help!!!
You can use the blobstore like a filesystem. Experimentally, they've even added access via the File api!
https://developers.google.com/appengine/docs/java/blobstore/overview#Writing_Files_to_the_Blobstore
You could also use the Google Cloud Storage. The advantage of this one is that once the file is produced, you can easily write scripts to manipulate the files through gsutil.

What would a good approach be for file storage and retrieval?

I am working on rewriting a Java web application to Rails which relies heavily on collections (100's or 1000's) of large (50-100MB) TIFF files. In the Java version, the user specifies a local root path (such as a mounted SAN drive) for these files in the application configuration, and they are read by the application using these paths. The application also writes new files to those paths.
Essentially, users must be able to add files to the application in two ways:
1) Specify a storage location as the 'root' for a collection of TIFFs, which could already contain many TIFFs. These are then processed.
2) Upload new files to an existing collection, which would then be written to the above path and processed.
I guess the gist of my question is: What is the standard way to store, retrieve, and write to such large files in the context of web applications? Should the availability of a local file system with enough storage space be assumed, or is there a better way to do it?
I would look into storing the files with paperclip or carrierwave. They are two great file upload and management gems that allow you to store your files in many different ways.
I have included links to two great sceencasts above and here are the github pages for paperclip and carrierwave.

Multiple file uploader with previews

I'm trying to find something that will let users upload multiple files to a website. The requirements are that it let them easily select multiple files (preferably with something like check boxes) and that it displays a preview of the images they select.
I'd prefer to only use Javascript or Flash if possible, but Java is also an option (this needs to work on platforms where Silverlight isn't available).
So far all I've been able to find are things that use the native file selector (which doesn't show previews on Windows, and makes it unclear that you can select multiple by holding ctrl).
I'm not sure if the preview requirement is even possible, but it's the most important.
This is a firefox solution:
It uses the FileReader javascript object to load, display and upload images.
http://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/
It still doesnt show previews in the FileSelection dialog but at least allows you to preview the images before uploading.
And here is a ready made java applet solution:
http://jumploader.com/doc_overview.html
To upload multiple files I use RichFaces rich:fileUpload component.
Concerning the preview, I've got the similar problem and the best I found after couple of days of googling is following.
Alfresco has the same problem and resolved it with :
An open office which runs in server mode (socket) and all the office documents are sent by alfresco to open office in order to convert them in PDF
Those PDF are converted to .swf viewer thanks to SWFTOOLS
This .swf is integrated in the HTML
For images, it uses ImageMagick to create small version of the file I suppose
Personnaly, I will try to implement it this way :
Converting office documents to PDF thanks to open office in socket mode
Transform the first page of the PDF into a PNG thanks to JPedal library
Diplay that PNG to the end user
For images I would perhaps use ImageMagick too ... but for now, I'm using Seam Image.scaleToFit API
I am assuming 2 things here:
1) Some kind of client/enduser will be doing the file upload
2) You get some kind of say on what the client installs on their computer to help make this happen.
If this is the case, my first suggestion would be:
Give them FTP or SFTP client software to upload files. The php page you make can have a link to Filezilla, along with instructions on how to use it. ftp and sftp are THE protocols to use for transferring files. HTTP is just not designed(well) for it, nor are browsers.
Once the user has the (S)FTP client software installed, you can give them URL's to upload files to that are specific to their user account, and you can have a backend script process and load/move files that they upload. It's pretty easy to create a local temporary directory using a server side script, have the client upload files via ftp, then go back to the web browser and click a button that says "Done uploading, please process my stuff".
The browser can even give back confirmations on everything that gets uploaded/processed.

Copying bulk documents (pdf files) from server to client machine with one click?

User selects the number of files (could be in 100s or 100s)
User clicks on the Download link.
User is presented a popup to provide the path on the client machine where the files are to be copied.
After providing the path, user clicks on Save button on the popup.
All the files would be copied from the server to the specified path on the client machine.
What could be the best way to achieve this with a J2EE based framework?
java.util.zip has classes that can assist you in creating a ZIP archive of the files.
I've never actually done this, but have thought about it from time to time:
Use MIME's multipart content type ability.
A quick google found detailed instructions in Download multiple files in one http request, although it is in ASP/VBS.

Categories