Starting with 2.0, uploaded files are not automatically bound to java attributes. It is expected that you get any uploaded file with request.getFileParameter() and save it manually. Loom provides several persistence implementations for uploaded files that can be used out-of-the-box.
PersistentFile is an useful abstraction that may be used for persisted files. While persisting, the file contents get separated from the file object depending on your persistence strategy:
Keeping the file metadata and its contents separated allows for flexible file management, keeping a list of files in the database and their content in some system folder, for example. It also is an effective workaround for handling large persistent files.
You can use one of the default FileManager implementation classes or roll your own:
Note that there is no JPA relationship between a PersistentFile and its contents. To get the contents, you should invoke fileManager.find() for each file.
Delivering persistent files from the server is quite easy:
public class FilesAction extends AbstractAction {
@Injected
private FileManager fileManager;
/** the id of the file to be retrieved */
private Integer id;
@Path("/{id}")
public Resolution getFile() {
return send(fileManager.find(id));
}
}