Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Static File Hosting

Joshua Zenn edited this page Mar 9, 2022 · 4 revisions

How To Add Your Own Files

  1. Place your file in the appropriate directory inside src/main/resources/static/. Do not put files in the static folder itself (except for the favicon).
  2. If you needed to create a new directory for the above step, make sure to add a security exception to src/main/java/com/virtudoc/web/configuration/SecurityConfiguration.java. It should be of the format /<directory>/**.<ext> or /<directory>/** if there are many kinds of extensions for that file type.
  3. Inside your view HTML file, reference the file with src="/<directory>/<filename>.<ext>" (replace src with the correct attribute name if it is not appropriate for your tag class).

Special Considerations

There are some things that you need to keep in mind when naming your files, as every proxy, web server, and file system that an HTTP request passes through will impose some restrictions on what symbols/characters you can use.

  • Filenames should be all lowercase, as Linux filesystems are often case-insensitive.
  • Filenames should not use spaces, as this can break some browsers.
  • File extensions should be all lowercase, as that is how the exceptions are written into SecurityConfig.java.

Images

  • Image files should be in PNG format as this is the smallest file type (uses vector format instead of actual pixel data) and does not suffer from compression artifacts like JPEG.

Emails

  • Email clients have no context for what our site URL is, so all image/asset references must be absolute (e.g. https://virtudoc.herokuapp.com/img/...). https://github.com/CS4850Group5A/VirtuDoc/issues/185 will bring some improvements to working with this edge case for asset hosting.