Cache file
  • 18 May 2022
  • 1 Minute to read
  • Dark
    Light
  • PDF

Cache file

  • Dark
    Light
  • PDF

Article Summary

Caches an external file to the file cache, returning a local filesystem path that can be used to open the file immediately elsewhere in the app.

Input arguments

LabelKeyTypeRequired?DefaultDescription
File URLurlString(url)YesExternal URL to download the file from.
HeadersheadersObjectNoHeaders to include in the HTTP call to download the file.
Time to livettlNumber(integer)No1209600The number of seconds the cached file will stay in the cache. Defaults to 2 weeks.
Allow self-signed SSL certificate?allowSelfSignedSSLBooleanNoIf true, allow files from URLs with self-signed SSL certificates to be downloaded.

Output arguments

Number of outputs: 2

LabelKeyTypeDescription
Cached filefileObjectObject describing the cached file in the local filesystem
  • Local path
file.pathStringAbsolute local filesystem path representing the file location on the device, including the filename and extension. On web, this is created via the [`createObjectURL`](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) method.
  • MIME type
file.mimeTypeStringMIME type of the file, if it could be determined.
  • Name
file.nameStringName of the file in the local filesystem, if applicable. Note that the filename and extension are included in the **Local path** property already.
  • Size
file.sizeNumberSize of the file, in bytes.
  • Created at
file.createdAtStringCreation datetime of the file, if it can be determined.
  • Modified at
file.modifiedAtStringDatetime when the file was last modified, if it can be determined.

Events

No events.

Errors

LabelCodeDescription
Unknown errorunknownThrown when trying to cache the file resulted in an unknown error.

Was this article helpful?