@polywrap/fs-plugin-js
TypeScript icon, indicating that this package has built-in type declarations

0.9.7 • Public • Published

@polywrap/fs-plugin-js

Filesystem Plugin allows the Polywrap JS Client to interact with the local filesystem.

Usage

import { PolywrapClient } from "@polywrap/client-js";
import { filesystemPlugin } from "@polywrap/fs-plugin-js";

// query a local wrapper
export async function foo({

  const filesystemPluginUri = "wrap://ens/fs.polywrap.eth";

  // initialize the client with eth, ipfs, ens plugins
  client = new PolywrapClient({
    plugins: [
      {
        uri: filesystemPluginUri,
        plugin: fileSystemPlugin({}),
      },
    ],
  });

  const sampleFilePath = path.resolve(__dirname, "samples/sample.txt");

  // and read from filesystem
  const response = await client.invoke<string>({
    filesystemPluginUri,
    method: "readFile",
    input: {
      path: sampleFilePath,
    },
  });

  // or instantiate the plugin
  const plugin = filesystemPlugin({});

  // and read from filesystem
  const response' = await plugin.readFile(
    { path: sampleFilePath, },
    client
  );
});

For more usage examples see src/__tests__.

API

  • readFile
  • readFileAsString
  • writeFile
  • exists
  • mkdir
  • rm
  • rmdir

Dependencies (1)

Dev Dependencies (13)

Package Sidebar

Install

npm i @polywrap/fs-plugin-js

Weekly Downloads

3

Version

0.9.7

License

MIT

Unpacked Size

67.4 kB

Total Files

25

Last publish

Collaborators

  • polywrap-build-bot
  • dorgjelli