Module io.jooby

Interface Asset

All Superinterfaces:
AutoCloseable

public interface Asset extends AutoCloseable
Represent an static resource file. Asset from file system and classpath are supported.
Since:
2.0.0
Author:
edgar
  • Method Details

    • create

      static Asset create(@NonNull Path resource)
      Creates a file system asset.
      Parameters:
      resource - File resource.
      Returns:
      File resource asset.
    • create

      static Asset create(@NonNull String path, @NonNull URL resource)
      Creates a URL asset with the given path.
      Parameters:
      path - Asset path.
      resource - Asset URL.
      Returns:
      URL asset.
    • getSize

      long getSize()
      Returns:
      Asset size (in bytes) or -1 if undefined.
    • getLastModified

      long getLastModified()
      Returns:
      The last modified date if possible or -1 when isn't.
    • isDirectory

      boolean isDirectory()
      Returns:
      True if the asset is a directory (when possible).
    • getEtag

      @NonNull default String getEtag()
      Computes a weak e-tag value from asset.
      Returns:
      A weak e-tag.
    • getContentType

      @NonNull MediaType getContentType()
      Returns:
      Asset media type.
    • stream

      InputStream stream()
      Returns:
      Asset content.