use of org.apache.wicket.util.resource.FileSystemResourceStream in project wicket by apache.
the class FileSystemResourceStreamReference method getReference.
@Override
public FileSystemResourceStream getReference() {
FileSystemResourceStream fileSystemResourceStream = new FileSystemResourceStream(Paths.get(absolutePath));
restoreResourceStream(fileSystemResourceStream);
return fileSystemResourceStream;
}
use of org.apache.wicket.util.resource.FileSystemResourceStream in project webanno by webanno.
the class AjaxDownloadLink method commonInit.
void commonInit() {
downloadBehavior = new AbstractAjaxBehavior() {
private static final long serialVersionUID = 3472918725573624819L;
@Override
public void onRequest() {
IResourceStream is = AjaxDownloadLink.this.getModelObject();
if (is != null) {
// If no filename has been set explicitly, try to get it from the resource
String name = filename != null ? filename.getObject() : null;
if (name == null) {
if (is instanceof FileResourceStream) {
name = ((FileResourceStream) is).getFile().getName();
} else if (is instanceof FileSystemResourceStream) {
name = ((FileSystemResourceStream) is).getPath().getFileName().toString();
}
}
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(AjaxDownloadLink.this.getModelObject(), name);
handler.setContentDisposition(ContentDisposition.ATTACHMENT);
getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
}
};
add(downloadBehavior);
}
Aggregations