Reference version

This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 51).

Expo FileSystem (next) iconExpo FileSystem (next)

GitHub

npm

A library that provides access to the local file system on the device.

Android
iOS
tvOS

expo-file-system provides access to a file system stored locally on the device.

Installation

Terminal
- npx expo install expo-file-system

If you are installing this in an existing React Native app (bare workflow), start by installing expo in your project. Then, follow the additional instructions as mentioned by library's README under "Installation in bare React Native projects" section.

Usage

API

Classes

Android
iOS
tvOS

Directory

Type: Class extends FileSystemDirectory

Directory Properties

Android
iOS
tvOS

exists

Type: boolean

A boolean representing if a directory exists. true if the directory exists, false otherwise.

Android
iOS
tvOS

uri

Read Only • Type: string

Represents the directory URI.

Directory Methods

Android
iOS
tvOS

copy(destination)

NameType
destinationDirectory | File

Copies a directory.

Returns:

any

Android
iOS
tvOS

create()

Creates a directory.

Returns:

void

Android
iOS
tvOS

delete()

Deletes a directory.

Returns:

void

Android
iOS
tvOS

move(destination)

NameType
destinationDirectory | File

Moves a directory.

Returns:

any

Android
iOS
tvOS

parentDirectory()

Returns:

Directory

Android
iOS
tvOS

File

Type: Class extends FileSystemFile

File Properties

Android
iOS
tvOS

exists

Type: boolean

A boolean representing if a file exists. true if the file exists, false otherwise.

Android
iOS
tvOS

md5

Type: null | string

An md5 hash of the file. Null if the file does not exist or it cannot be read.

Android
iOS
tvOS

size

Type: null | number

A size of the file in bytes. Null if the file does not exist or it cannot be read.

Android
iOS
tvOS

uri

Read Only • Type: string

Represents the file URI.

File Methods

Android
iOS
tvOS

base64()

Retrieves content of the file as base64.

Returns:

string

The contents of the file as a base64 string.

Android
iOS
tvOS

copy(destination)

NameType
destinationDirectory | File

Copies a file.

Returns:

any

Android
iOS
tvOS

create()

Creates a file.

Returns:

void

Android
iOS
tvOS

delete()

Deletes a file.

Returns:

void

Android
iOS
tvOS

downloadFileAsync(url, destination)

NameTypeDescription
urlstring

The URL of the file to download.

destinationDirectory | File

The destination directory or file. If a destination is provided, the resulting filename will be determined based on the response headers.


Downloads a file from the network.

Returns:

Promise<File>

A promise that resolves to the downloaded file.

Android
iOS
tvOS

extension()

Returns:

string

Android
iOS
tvOS

move(destination)

NameType
destinationDirectory | File

Moves a directory.

Returns:

any

Android
iOS
tvOS

parentDirectory()

Returns:

Directory

Android
iOS
tvOS

text()

Retrieves text from the file.

Returns:

string

The contents of the file as string.

Android
iOS
tvOS

write(content)

NameTypeDescription
contentstring

The content to write into the file.


Writes content to the file.

Returns:

void

Namespaces

Android
iOS
tvOS

Paths

Paths Methods

Android
iOS
tvOS

basename(path, ext)

NameType
pathstring
ext
(optional)
string

Returns:

string

Android
iOS
tvOS

dirname(path)

NameType
pathstring

Returns:

string

Android
iOS
tvOS

isAbsolute(path)

NameType
pathstring

Returns:

boolean

Android
iOS
tvOS

join(...paths)

NameType
...pathsstring[]

Returns:

string

Android
iOS
tvOS

normalize(path)

NameType
pathstring

Returns:

string

Android
iOS
tvOS

parse(path)

NameType
pathstring

Returns:

{ base: string, dir: string, ext: string, name: string, root: string }

Android
iOS
tvOS

relative(from, to)

NameType
fromstring
tostring

Returns:

string