- Download the source code and open the NetBeans project contained within.
- Edit the class MessageService as follows:
- Change the constant BASE_DIR to point to an existing directory on your server (or localhost) where you want to store the images.
- Change the constant MAX_SIZE_IN_MB to the maximum allowed size you want to use. You will not be able to upload or download images larger than this size.
- Deploy the application to GlassFish.
- Drop some images (with extension .jpg or .png and not larger than the maximum allowed size) into the BASE_DIR folder you configured or use upload.html to upload some images (see below).
Using the webservice
The webservice uses the following URLs:
- GET this URL to get a list of available images (filenames wrapped in a JSON array).
- POST to this URL to upload an image. The server will store this image and pick a random filename for it.
- GET this URL to download the image with the given filename.
If you change any of these, make sure you update the BASE_URL variables in upload.js and download.js as well.
Using the front-end
The front-end consists of the following pages:
- Use this page to upload an image via an HTML form.
- Use this page to get a list of available images and to download them.
If you have any questions or find a bug, feel free to send me an email, or leave a comment!