or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

directory-operations.mdfile-operations.mdindex.mdnetwork-operations.mdpickers.mdstreaming.mdsystem-paths.md
tile.json

index.mddocs/

Expo File System

Expo File System provides comprehensive access to the local file system on mobile devices through Expo's module system. It offers a modern, object-oriented API for file and directory operations including reading, writing, copying, moving, and deleting files and directories with cross-platform support for iOS and Android.

Package Information

  • Package Name: expo-file-system
  • Package Type: npm
  • Language: TypeScript
  • Installation: npx expo install expo-file-system
  • Platforms: iOS, Android
  • Expo SDK: Compatible with Expo SDK 50+

Core Imports

import { File, Directory, Paths } from "expo-file-system";

For legacy compatibility:

import * as FileSystem from "expo-file-system/legacy";

Type imports:

import type { FileInfo, DirectoryInfo, FileCreateOptions } from "expo-file-system";

Basic Usage

import { File, Directory, Paths } from "expo-file-system";

// Create file and directory instances
const file = new File(Paths.document, "myfile.txt");
const directory = new Directory(Paths.cache, "temp");

// Basic file operations
file.write("Hello, World!");
const content = await file.text();
console.log(content); // "Hello, World!"

// Directory operations
directory.create();
const files = directory.list();

// Check disk space
console.log(`Available space: ${Paths.availableDiskSpace} bytes`);

Architecture

Expo File System is built around several key components:

  • Modern API: Object-oriented File and Directory classes with fluent interfaces
  • System Access: Paths class providing access to cache, document, and bundle directories
  • Streaming Support: ReadableStream and WritableStream for large file operations
  • Cross-platform: Unified API with platform-specific optimizations
  • Legacy Compatibility: Backwards compatibility layer for existing codebases
  • Type Safety: Full TypeScript support with comprehensive type definitions

Capabilities

File Operations

Complete file management including creation, reading, writing, copying, moving, and deletion. Supports both synchronous and asynchronous operations with streaming for large files.

class File implements Blob {
  constructor(...uris: (string | File | Directory)[]);
  readonly uri: string;
  readonly name: string;
  readonly extension: string;
  readonly parentDirectory: Directory;
  exists: boolean;
  size: number;
}

File Operations

Directory Operations

Directory management including creation, listing contents, copying, moving, and deletion. Provides recursive operations and metadata access.

class Directory {
  constructor(...uris: (string | File | Directory)[]);
  readonly uri: string;
  readonly name: string;
  readonly parentDirectory: Directory;
  exists: boolean;
  size: number | null;
}

Directory Operations

System Directories and Paths

Access to system directories (cache, document, bundle) and comprehensive path manipulation utilities with cross-platform compatibility.

class Paths extends PathUtilities {
  static get cache(): Directory;
  static get document(): Directory;
  static get bundle(): Directory;
  static get appleSharedContainers(): Record<string, Directory>;
  static get totalDiskSpace(): number;
  static get availableDiskSpace(): number;
  static info(...uris: string[]): PathInfo;
}

System Directories and Paths

Streaming Operations

Readable and writable streams for efficient handling of large files with backpressure control and memory-efficient processing.

interface FileHandle {
  offset: number | null;
  size: number | null;
  close(): void;
  readBytes(length: number): Uint8Array<ArrayBuffer>;
  writeBytes(bytes: Uint8Array): void;
}

Streaming Operations

Network Operations

Download files from URLs with progress tracking and resume capabilities. Supports custom headers and destination control.

class File {
  static downloadFileAsync(
    url: string,
    destination: Directory | File,
    options?: DownloadOptions
  ): Promise<File>;
}

Network Operations

File System Pickers

Native file and directory pickers for user-initiated file selection with platform-specific behaviors and MIME type filtering.

class File {
  static pickFileAsync(initialUri?: string, mimeType?: string): Promise<File | File[]>;
}

class Directory {
  static pickDirectoryAsync(initialUri?: string): Promise<Directory>;
}

File System Pickers

Core Types

interface FileInfo {
  exists: boolean;
  uri?: string;
  size?: number;
  modificationTime?: number;
  creationTime?: number;
  md5?: string;
}

interface DirectoryInfo {
  exists: boolean;
  uri?: string;
  size?: number;
  modificationTime?: number;
  creationTime?: number;
  files?: string[];
}

interface PathInfo {
  exists: boolean;
  isDirectory: boolean | null;
}

interface FileCreateOptions {
  intermediates?: boolean;
  overwrite?: boolean;
}

interface DirectoryCreateOptions {
  intermediates?: boolean;
  overwrite?: boolean;
  idempotent?: boolean;
}

interface InfoOptions {
  md5?: boolean;
}

interface DownloadOptions {
  headers?: { [key: string]: string };
}