Reputation:
I have a bunch of public assets that I would like to zip and provide for download.
Is there an easy way in Play! to create a zip for a list of files/folders?
Upvotes: 1
Views: 1378
Reputation: 1432
In the controller use this:
public class Public extends Controller {
public static void download() {
File dir = VirtualFile.fromRelativePath("/dir-to-zip/").getRealFile();
File zip = VirtualFile.fromRelativePath("/files.zip").getRealFile();
Files.zip(dir, zip);
renderBinary(zip);
}
}
Then add this to your routes file:
* /download Public.download
Note that file paths are from your application root, not your file system root.
Upvotes: 0
Reputation: 3456
play war "project_dir" -o "war_file_name" --zip
Note: I'm using Play-1.2.3
Upvotes: 0
Reputation: 5947
I suppose you can always use Java libraries. See JavaDocs for details
Upvotes: 2