HomeGuidesReferenceLearn

Reference version

ArchiveExpo SnackDiscord and ForumsNewsletter
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

path

Read Only • Type: string

Represents the directory path.

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

exists()

Checks if a directory exists.

Returns:

boolean

true if the directory exists, false otherwise.

Android
iOS
tvOS

move(destination)

NameType
destinationDirectory | File

Moves a directory.

Returns:

any

Android
iOS
tvOS

File

Type: Class extends FileSystemFile

File Properties

Android
iOS
tvOS

path

Read Only • Type: string

Represents the file path.

File Methods

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

exists()

Checks if a file exists.

Returns:

boolean

true if the file exists, false otherwise.

Android
iOS
tvOS

move(destination)

NameType
destinationDirectory | File

Moves a directory.

Returns:

any

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

Methods

Android
iOS
tvOS

FileSystem Next.write(file, contents)

NameType
fileFile
contentsstring

Returns:

Promise<void>