> For the complete documentation index, see [llms.txt](https://docs.microart.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.microart.app/packages/microart-fs/main.md).

# Main

## Default Export

```typescript
import fs from '@microart/fs';

// use like regular, simply proxies to internal nodejs 'fs' module
fs.readdirSync();
```

## FileSystem class

The file system class is where the magic of the library comes from. It allows you to setup all sorts of providers to retrieve files and information.

```typescript
import { FileSystem } from '@microart/fs';

const { fs } = new FileSystem();
```

*Default config, same as importing just fs or using the builtin fs module*

```typescript
const { fs } = new FileSystem({
    provider: example provider instance
});
```

Using a custom provider

## Providers:

## LocalProvider

```typescript
import { LocalProvider } from '@microart/fs';

const { fs } = new FileSystem({
    provider: new LocalProvider({
        root: './', // maps '/' to whatever './' is
    })
});

// Regular
fs.readdirSync('/');
// home, boot, etc, mnt, var, usr, root, lib

// FileSystem with root mapped to './'
fs.readdirSync('/');
// index.js, node_modules
```

## ProxyProvider

```typescript
import { ProxyProvider } from '@microart/fs';

const { fs } = new FileSystem({
    provider: new ProxyProvider({
        getItems() {
            return [
                {
                    name: "Test Folder",
                    type: "folder",
                    getItems() {
                        return [];
                    }
                }
            ]
        }
    })
});

fs.readdirSync('/');
// Test Folder
```

## S3Provider

```typescript
import { S3Provider } from '@microart/fs';

const { fs } = new FileSystem({
    provider: new S3Provider({
        endpoint: '',
        region: '',
        accessKey: '',
        accessSecret: '',
    })
});

fs.readdirSync('/');
// folder1, test-folder2, examplefolder
```

## FTPProvider

```typescript
import { FTPProvider } from '@microart/fs';

const { fs } = new FileSystem({
    provider: new FTPProvider({
        host: '',
        port: '',
        username: '',
        password: '',
    })
});

fs.readdirSync('/');
// folder1, test-folder2, examplefolder
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.microart.app/packages/microart-fs/main.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
