use of org.apache.wicket.util.resource.FileResourceStream in project wicket by apache.
the class FileResourceStreamReference method getReference.
@Override
public FileResourceStream getReference() {
FileResourceStream fileResourceStream = new FileResourceStream(new File(fileName));
restoreResourceStream(fileResourceStream);
return fileResourceStream;
}
use of org.apache.wicket.util.resource.FileResourceStream in project wicket by apache.
the class CachingResourceStreamLocator method updateCache.
private void updateCache(CacheKey key, IResourceStream stream) {
if (null == stream) {
cache.put(key, NullResourceStreamReference.INSTANCE);
} else if (stream instanceof FileResourceStream) {
FileResourceStream fileResourceStream = (FileResourceStream) stream;
cache.put(key, new FileResourceStreamReference(fileResourceStream));
} else if (stream instanceof UrlResourceStream) {
UrlResourceStream urlResourceStream = (UrlResourceStream) stream;
cache.put(key, new UrlResourceStreamReference(urlResourceStream));
}
}
use of org.apache.wicket.util.resource.FileResourceStream in project wicket by apache.
the class DownloadLink method onClick.
@Override
public void onClick() {
final File file = getModelObject();
if (file == null) {
throw new IllegalStateException(getClass().getName() + " failed to retrieve a File object from model");
}
String fileName = fileNameModel != null ? fileNameModel.getObject() : null;
if (Strings.isEmpty(fileName)) {
fileName = file.getName();
}
IResourceStream resourceStream = new FileResourceStream(new org.apache.wicket.util.file.File(file));
getRequestCycle().scheduleRequestHandlerAfterCurrent(new ResourceStreamRequestHandler(resourceStream) {
@Override
public void respond(IRequestCycle requestCycle) {
super.respond(requestCycle);
if (deleteAfter) {
Files.remove(file);
}
}
}.setFileName(fileName).setContentDisposition(contentDisposition).setCacheDuration(cacheDuration));
}
use of org.apache.wicket.util.resource.FileResourceStream in project ocvn by devgateway.
the class FolderContentResource method respond.
public void respond(final Attributes attributes) {
PageParameters parameters = attributes.getParameters();
String fileName = parameters.get(PARAM_FILE_NAME).toString();
// we use FilenameUtils to prevent "security tricks", only a file name
// without path is allowed
File file = new File(rootFolder, FilenameUtils.getName(fileName));
FileResourceStream fileResourceStream = new FileResourceStream(file);
ResourceStreamResource resource = new ResourceStreamResource(fileResourceStream);
resource.respond(attributes);
}
use of org.apache.wicket.util.resource.FileResourceStream in project oc-explorer by devgateway.
the class FolderContentResource method respond.
public void respond(final Attributes attributes) {
PageParameters parameters = attributes.getParameters();
String fileName = parameters.get(PARAM_FILE_NAME).toString();
// we use FilenameUtils to prevent "security tricks", only a file name
// without path is allowed
File file = new File(rootFolder, FilenameUtils.getName(fileName));
FileResourceStream fileResourceStream = new FileResourceStream(file);
ResourceStreamResource resource = new ResourceStreamResource(fileResourceStream);
resource.respond(attributes);
}
Aggregations