afzalex
afzalex

Reputation: 8652

Making a directory accessible to get files in it through url

I have a directory containing images. Images are added in it at any time, during runtime. I want to make these files visible through some url.

I tried to put this directory in wildfly webapp directory. But the images added at runtime are not visible.

How to make this directory accessible.

Upvotes: 1

Views: 247

Answers (2)

James R. Perkins
James R. Perkins

Reputation: 17815

You can add a file handler in the undertow subsystem and map it to a URL. In CLI you'd execute something similar to the following to commands.

/subsystem=undertow/configuration=handler/file=images:add(directory-listing=true, follow-symlink=true, path=/path/to/image/directory)
/subsystem=undertow/server=default-server/host=default-host/location=\/images:add(handler=images)

That would list all the images on localhost:8080/images. You can turn off the directory listing and/or use a complete image URL to see the specific image.

Upvotes: 1

jpkroehling
jpkroehling

Reputation: 14061

In your deployments, create a new directory with the .war extension, as:

$WILDFLY_HOME/standalone/deployments/images.war/

This is an "exploded" deployment, and any new images added there can be reached via:

http://localhost:8080/images/

Upvotes: 0

Related Questions