File
A file
Returned by a directory's file(). Reads and writes text, JSON, images and raw data, and reports size, dates and extended attributes.
Properties
pathStringFile path
nameStringFile name
extensionStringFile extension
existsBooleanWhether this file exists
sizeNumberFile size in bytes
utiStringUniform type identifier
createdAtDateTime ›File creation date
modifiedAtDateTime ›File modification date
iCloudAnyiCloud metadata
tags[String]File tags
attributesAnyFile attributes
Methods
.read(as?)AnyRead file contents. Modes: 'string', 'json', 'image', 'data' (a Data value with the file's bytes).
- as String
.write(content)Write content to this file. A Data or image value is written as its bytes; anything else as text.
- content string | Data | Image required
Text is written as UTF-8; a Data or image value as its bytes.
.append(content)Append text to this file.
- content String required
.copyTo(destination)Copy this file to a destination.
- destination Any required
.moveTo(destination)Move this file to a destination.
- destination Any required
.delete()Delete this file.
.download()BooleanTrigger iCloud download for this file.