Cache file

Caches an external file to the file cache

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

Label

Key

Type

Required?

Default

Description

File URL

url

String(url)

Yes

External URL to download the file from.

Headers

headers

Object

No

Headers to include in the HTTP call to download the file.

Time to live

ttl

Number(integer)

No

1209600

The number of seconds the cached file will stay in the cache. Defaults to 2 weeks.

Allow self-signed SSL certificate?

allowSelfSignedSSL

Boolean

No

If true, allow files from URLs with self-signed SSL certificates to be downloaded.

Output arguments

Number of outputs: 2

Label

Key

Type

Description

Cached file

file

Object

Object describing the cached file in the local filesystem

  • Local path

file.path

String

Absolute 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.mimeType

String

MIME type of the file, if it could be determined.

  • Name

file.name

String

Name 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.size

Number

Size of the file, in bytes.

  • Created at

file.createdAt

String

Creation datetime of the file, if it can be determined.

  • Modified at

file.modifiedAt

String

Datetime when the file was last modified, if it can be determined.

Events

No events.

Errors

Label

Code

Description

Unknown error

unknown

Thrown when trying to cache the file resulted in an unknown error.