Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

expo-file-system

Package Overview
Dependencies
Maintainers
33
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expo-file-system

Provides access to the local file system on the device.

  • 18.0.0-canary-20241018-75a0b25
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
835K
increased by1.24%
Maintainers
33
Weekly downloads
 
Created

What is expo-file-system?

The expo-file-system package provides access to the file system on the device, allowing for reading, writing, deleting, and managing files and directories. It is part of the Expo ecosystem and is designed to work seamlessly with other Expo modules.

What are expo-file-system's main functionalities?

Reading Files

This feature allows you to read the contents of a file from a given URI. The readAsStringAsync method reads the file and returns its content as a string.

import * as FileSystem from 'expo-file-system';

async function readFile(uri) {
  try {
    const content = await FileSystem.readAsStringAsync(uri);
    console.log(content);
  } catch (error) {
    console.error('Error reading file:', error);
  }
}

Writing Files

This feature allows you to write content to a file at a specified URI. The writeAsStringAsync method writes the provided content to the file.

import * as FileSystem from 'expo-file-system';

async function writeFile(uri, content) {
  try {
    await FileSystem.writeAsStringAsync(uri, content);
    console.log('File written successfully');
  } catch (error) {
    console.error('Error writing file:', error);
  }
}

Deleting Files

This feature allows you to delete a file at a specified URI. The deleteAsync method deletes the file.

import * as FileSystem from 'expo-file-system';

async function deleteFile(uri) {
  try {
    await FileSystem.deleteAsync(uri);
    console.log('File deleted successfully');
  } catch (error) {
    console.error('Error deleting file:', error);
  }
}

Creating Directories

This feature allows you to create a directory at a specified URI. The makeDirectoryAsync method creates the directory, and the intermediates option allows for creating intermediate directories if they do not exist.

import * as FileSystem from 'expo-file-system';

async function createDirectory(uri) {
  try {
    await FileSystem.makeDirectoryAsync(uri, { intermediates: true });
    console.log('Directory created successfully');
  } catch (error) {
    console.error('Error creating directory:', error);
  }
}

Downloading Files

This feature allows you to download a file from a remote URI to a local URI. The downloadAsync method handles the download process.

import * as FileSystem from 'expo-file-system';

async function downloadFile(uri, downloadUri) {
  try {
    const { uri: localUri } = await FileSystem.downloadAsync(downloadUri, uri);
    console.log('File downloaded to:', localUri);
  } catch (error) {
    console.error('Error downloading file:', error);
  }
}

Other packages similar to expo-file-system

Keywords

FAQs

Package last updated on 18 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc