Package com.castlabs.android.downloader

## Class DownloadableResource

- java.lang.Object
- - com.castlabs.android.downloader.DownloadableResource

-     public class DownloadableResource
      extends Object

  Model that is used to add resources to a download session when implementing `Downloadable`.

  Please note that you usually do not interact with the class. It is used by other plugins to expose a downloader resource and it is port of the core SDK to avoid an explicit dependency to the Downloader Plugin.

  Since:
    4.0.0

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `long` | `length` | The length in bytes or `SdkConsts.LENGTH_UNBOUNDED` if unknown
    `String` | `target` | The absolute path to the local target path.
    `int` | `type` | The chunk type, for example `SdkConsts.THUMBNAIL`.
    `Uri` | `uri` | The sources URL

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DownloadableResource()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static File` | `createTarget​(Uri resource, File basePath, String remoteManifestUrl, boolean relativeToManifest)` | Create a path to a local file given the remote resource, the manifest URL and the base path.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### uri

          public Uri uri

      The sources URL

    - #### target

          public String target

      The absolute path to the local target path. See `createTarget(Uri, File, String, boolean)` to generate teh local path.

    - #### type

          public int type

      The chunk type, for example `SdkConsts.THUMBNAIL`.

    - #### length

          public long length

      The length in bytes or `SdkConsts.LENGTH_UNBOUNDED` if unknown

  - ### Constructor Detail

    - #### DownloadableResource

          public DownloadableResource()

  - ### Method Detail

    - #### createTarget

          public static File createTarget​(@NonNull
                                          Uri resource,
                                          @NonNull
                                          File basePath,
                                          @Nullable
                                          String remoteManifestUrl,
                                          boolean relativeToManifest)

      Create a path to a local file given the remote resource, the manifest URL and the base path. If specified, this will create a target folder relative to the manifest if that is possible, i.e. the manifest comes from the same host and has the same base path structure.
      Parameters:
        `resource` - The URL to the resource to download
        `basePath` - The target folder base path
        `remoteManifestUrl` - The URL to the manifest
        `relativeToManifest` - If true, this will try to resolve a path relative to the manifest
      Returns:
        The local target path for this resource