Recent searches

in

FileMetadata

On this page

Represents metadata describing a file. Returned by the metadata() method on a File.

Type

Object

Properties

file_sizenumber | null#

Holds the file's size in bytes (the length of its raw source), or null if unknown.

Available on: FileMetadata.

Show examplesHide examples

In this example, we read the size of the file open in the editor.

JavaScript
Copied to clipboard
const { file_size } = await api.currentFile().metadata();
console.log(file_size);
created_atstring | null#

Holds an ISO 8601 timestamp of when the file was created, or null if unknown.

Available on: FileMetadata.

Show examplesHide examples

In this example, we read when the file was created.

JavaScript
Copied to clipboard
const { created_at } = await api.currentFile().metadata();
console.log(`Created at ${new Date(created_at).toLocaleString()}`);
last_modifiedstring | null#

Holds a timestamp of the file's most recent change, or null if unknown.

Available on: FileMetadata.

Show examplesHide examples

In this example, we read when the file was last changed.

JavaScript
Copied to clipboard
const { last_modified } = await api.currentFile().metadata();
console.log(last_modified);
dataany#

Holds the file's resolved output data: its front matter merged with the data CloudCannon's build produces for it. The shape depends on the file, so this is loosely typed.

Available on: FileMetadata.

Show examplesHide examples

In this example, we read the file's resolved output data.

JavaScript
Copied to clipboard
const { data } = await api.currentFile().metadata();
console.log(data);
Open in a new tab