as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

@amazon-devices/kepler-file-system

The Kepler File System API provides support to Kepler by enabling file system querying, traversing, reading, and writing operations.

Remarks

Apps operate in a sandboxed environment with a restricted view of the device file system. Kepler makes the following app-specific directories available in the sandbox.

Path Writeable Description
/pkg No The root of the app package.
/pkg/assets No Assets installed by the package.
/pkg/lib No App entry point component and any additional libraries installed by the package.
/data Yes Writable location for the app data. Persistent across device reboots and package upgrades, not shared between apps or services. This directory isn't persistent on app uninstall.
/tmp Yes Each app gets its own temporary storage, which cannot be shared with any other apps or services. Non-persistent, will be removed during device reboot.
/proc No Only /proc/self is available to the app.

Get started

Setup

  1. Add the following library dependency to the dependencies section of your package.json file.

    Copied to clipboard.

     "@amazon-devices/kepler-file-system": "~0.0.1"
    
  2. Regenerate the package-lock.json file using the npm install command.

Usage

The following examples use async/await to handle Promises returned by FileSystem methods. This pattern provides a cleaner way to work with asynchronous operations.

Open a file

This example uses async/await to handle the Promise returned by FileSystem.openFile().

Copied to clipboard.

import { KeplerFileSystem as FileSystem } from '@amazon-devices/kepler-file-system';

const handleOpenFile = async () => {
  FileSystem.openFile('/data/fileSystemTestFile', 0)
    .then((response: any) => console.log(response))
    .catch((error: any) => console.error(error));
};

Remove a file

This example uses async/await to handle the Promise returned by FileSystem.removeFile().

Copied to clipboard.

import { KeplerFileSystem as FileSystem } from '@amazon-devices/kepler-file-system';

const handleRemoveFile = async () => {
  FileSystem.removeFile('/data/fileSystemTestFile')
    .then((response: any) => console.log(response))
    .catch((error: any) => console.error(error));
};

Remove a directory

This example uses async/await to handle the Promise returned by FileSystem.removeDir().

Copied to clipboard.

import { KeplerFileSystem as FileSystem } from '@amazon-devices/kepler-file-system';

const handleRemoveDir = async () => {
  FileSystem.removeDir('/data')
    .then((response: any) => console.log(response))
    .catch((error: any) => console.error(error));
};

Remove a directory recursively

This example uses async/await to handle the Promise returned by FileSystem.removeDirAll().

Copied to clipboard.

import { KeplerFileSystem as FileSystem } from '@amazon-devices/kepler-file-system';

const handleRemoveDirAll = async () => {
  FileSystem.removeDirAll('/data')
    .then((response: any) => console.log(response))
    .catch((error: any) => console.error(error));
};

Read a file as a string

This example uses async/await to handle the Promise returned by FileSystem.readFileAsString().

Copied to clipboard.

import { KeplerFileSystem as FileSystem } from '@amazon-devices/kepler-file-system';

const handleReadFileAsString = async () => {
  FileSystem.readFileAsString('/data/fileToReadWrite', 'UTF-8')
    .then((response: any) => console.log(response))
    .catch((error: any) => console.error(error));
};

Write a string to a file

This example uses async/await to handle the Promise returned by FileSystem.writeStringToFile().

Copied to clipboard.

import { KeplerFileSystem as FileSystem } from '@amazon-devices/kepler-file-system';

const handleWriteStringToFile = async () => {
  FileSystem.writeStringToFile('/data/fileToReadWrite', 'Hello world!', 'UTF-8')
    .then((response: any) => console.log(response))
    .catch((error: any) => console.error(error));
};

Access file metadata

This example uses async/await to handle the Promise returned by FileSystem.getMetadata().

Copied to clipboard.

import { KeplerFileSystem as FileSystem } from '@amazon-devices/kepler-file-system';

export const handleGetMetadata = async () => {
  FileSystem.getMetadata('/data/fileSystemTestFile', false)
    .then((response: any) => console.log(response))
    .catch((error: any) => console.error(error));
};

Access directory entries

This example uses async/await to handle the Promise returned by FileSystem.getEntries().

Copied to clipboard.

import { KeplerFileSystem as FileSystem } from '@amazon-devices/kepler-file-system';

const handleGetEntries = async () => {
  FileSystem.getEntries('/data')
    .then((response: any) => console.log(response))
    .catch((error: any) => console.error(error));
};

Modules


Last updated: Sep 30, 2025