Class Resource

java.lang.Object
com.aoapps.cdn.data.Resource

public class Resource extends Object
A resource has both the originally uploaded content as well as any number of derived versions. Derived versions include things like scaling size, reducing quality, change frame rates, bit speeds, and such. Derived versions may be of a different content type than the original, such as when a thumbnail image is extracted from the first frame of an mp4.

TODO: Versions may have a different content type than the original, such as the first-frame still image for a video file. This means that a resource may be access by different extensions, even for original unqualified: xyz.mp4 would redirect to original version video xyz.jpg would redirect to version of first frame at original video size xyz-(width)x(height).mp4 would be scaled video xyz-(width)x(height).jpg would be scaled first frame

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getCdnData

      public CdnData getCdnData()
      Gets the CDN this resource is part of.
    • getId

      public SmallIdentifier getId()
      Gets the unique identifier for this resource.
    • getVersions

      public List<Version> getVersions(ContentType contentType) throws IOException
      Gets all versions of this resource, optionally filtered by content type.
      Parameters:
      contentType - The optional content type to filter for or null for any content type
      Throws:
      IOException
    • getVersions

      public List<Version> getVersions() throws IOException
      Gets all versions of this resource.
      Throws:
      IOException
    • getOriginalContentType

      public ContentType getOriginalContentType() throws IOException, IllegalArgumentException
      Determines the original content type by looking for the "original.(extension)" entry. This is expected to be a symlink to the scaled name pattern, but this is not specifically checked; only filenames are scanned.

      Resource locking not performed since the original version is created for a new resource then effectively immutable (never modified).

      Throws:
      IllegalArgumentException - When unable to determine the content type
      IOException
    • getOriginal

      public Version getOriginal() throws IOException
      Gets the original version of this resource by following the original symlink and parsing the filename.

      No resource locking required since the original version is created for a new resource then effectively immutable (never modified).

      Throws:
      IOException