Wicket 7.x handle external resource directory/file requests - wicket

I wanna handle requests to image resources like this:
<img src="images?file=sub/path/to/myImage.jpg" />
The key "images" is an alias for a mounted resource somewhere on my local hard drive:
/base/path/to/all/images
that contains the subdirectory
sub/path/to
where the requested image
myImage.jpg
is located.
So the full image path is:
/base/path/to/all/images/sub/path/to/myImage.jpg
I've tried to mount a request mapper using:
public void WebApplication#mount(final IRequestMapper mapper) {...}
but I really don't understand what to do.
Can someone help me?

Please check http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/ and the demo application linked at the bottom. It does almost the same.

Related

Why google search console need to verify dns txt?

First I build blog in hugo and deploy with netlify.
Verifying with file or txt, it isn't rendered in my case. I try to put content folder, also themes folder. So i found alternative way using google Web master center. And then, just add html tag. Finally, I got Verification completed. But, I can't use search console, yet. Because I'm not verified.
Why and How can correct?
If you want static content, rendered as-is, place it in Hugo's static directory and it will be added directly to the output public directory without alteration. Alternatively, you could use a meta tag to verify; just place that in your base layout; typically layouts/_default/baseofhtml.html

SLIM API - Offer Files to Download

I am using Slim API for my Project. I want to offer Files for Download (Mostly PDF files). I found several Ways sending out a public link to the file, which i dont want. I also found an Middleware for the Version 2.4 of Slim, but I am using 3.x.
I just want to access the Route e.g. /downloads/version/2183
And the a Downlod with this certain File ID should start. I have a Path to the File on the Server in a variable available.
The Basic Idea behind is different restrictions, which user can download the file - but i can do that myself - the problem where I am stuck is, how to bring the Download over the Route to the Clients Browser
Does anyone know how to achieve this?
Cheers,
Niklas
This is actually very easy.
Set the Proper Headers for the file on the Response Object
Read the contents of the file into the body of the Response Object
$app->get('/my/file', function ($req, $res, $args) {
return $res->withHeader('Content-Type', 'application/octet-stream')
->withHeader('Content-Disposition', 'attachment')
->write(file_get_contents("file.txt"));
});

Not able to access image on jsp file

Attaches is the image of my project hierarchy. I am trying to call image from images directory to the jsp file in jsp directory but I am getting blank screen.
So far I have tried :
/WEB-INF/images/'<'imageFileName'>'
/images/'<'imageFileName'>'
/'<'imageFileName'>'
src/main/webapp/WEB-INF/images/'<'imageFileName'>'
Please help me on this.
You can't access any resources that are under WEB-INF folder, it serves just that purpose, to hold the resources that are not directly visible for the public but available to the classloader (servlets) of your web app.
You should make a mapping by the means of mvc:resources element, you should checkout the docs
for your particular case a mapping like
<mvc:resources mapping="/images/**" location="/WEB-INF/images"/>
should work out, and you'll be able to browse your images via request such as
/images/'<'imageFileName'>'
You can place your images and jsp folder under the web-app folder rather than WEB-INF folder. Then you can access the images using:
/images/'<'imageFileName'>'
The JSPs cannot access files inside WEB-INF folder directly, since it's not publicly available. But you can access it indirectly through a Servlet which will return the Image's stream object.
The sample code to access files in WEB-INF folder is in the below link. Have a look.
http://simple.souther.us/ar01s10.html

Dropbox: how do I get the ACL for a file?

Given a file, how can I find who the file is visible to (shared with)?
This doesn't appear to be in metadata, and the /shares path generates a link.
So, how can we tell who has access?
The Dropbox API currently does not offer a way to find the shared status of files like this.

Defining Paths / URL within JaxWS web service,

I want to wrap an executable (Fortran application) as a web service. In order to execute my application I have to generate a bunch of files from the user's input including paths to specific resources (The user may upload resources to be used before starting the service). When done I generate a result file which should be downloadable so I want to return a URL. The paths to the resources should not be accessible but the URL (of course) should enable downloading.
How do I get these paths? Is servlet context the correct approach? My service isn't a servlet and therefore has no context, has it?
Thanks in advance!
I was able to solve this problem with the help of WSContext and the ServletContext which gives me the path to Context root. Everything that is not supposed to be accessed from outside will be placed under WEB-INF, all accessible sources will be placed under COntext root and subfolders. (I am working on the last bit)
Very important: I injected WSContext via #Resource and you have to access the WSContext AFTER the constructor is done. I tried to use the context within the constructor and that gave me a hard time because it was always null then.