Apache OpenDAL™ - v0.48.1
    Preparing search index...

    Class Operator

    Index

    Constructors

    Methods

    • Check if this operator can work correctly.

      We will send a list request to the given path and return any errors we met.

      await op.check();
      

      Returns Promise<void>

    • Check the op synchronously.

      op.checkSync();
      

      Returns void

    • Copy file according to given from and to path.

      await op.copy("path/to/file", "path/to/dest");
      

      Parameters

      • from: string
      • to: string

      Returns Promise<void>

    • Copy file according to given from and to path synchronously.

      op.copySync("path/to/file", "path/to/dest");
      

      Parameters

      • from: string
      • to: string

      Returns void

    • Create dir with a given path.

      await op.createDir("path/to/dir/");
      

      Parameters

      • path: string

      Returns Promise<void>

    • Create dir with a given path synchronously.

      op.createDirSync("path/to/dir/");
      

      Parameters

      • path: string

      Returns void

    • Delete the given path.

      Delete not existing error won’t return errors.

      await op.delete("test");
      

      Parameters

      • path: string

      Returns Promise<void>

    • Delete the given path synchronously.

      op.deleteSync("test");
      

      Parameters

      • path: string

      Returns void

    • Check if this path exists or not.

      await op.isExist("test");
      

      Parameters

      • path: string

      Returns Promise<boolean>

    • Check if this path exists or not synchronously.

      op.isExistSync("test");
      

      Parameters

      • path: string

      Returns boolean

    • List the given path.

      This function will return an array of entries.

      An error will be returned if given path doesn't end with /.

      const list = await op.list("path/to/dir/");
      for (let entry of list) {
      let meta = await op.stat(entry.path);
      if (meta.isFile) {
      // do something
      }
      }

      With recursive option, you can list recursively.

      const list = await op.list("path/to/dir/", { recursive: true });
      for (let entry of list) {
      let meta = await op.stat(entry.path);
      if (meta.isFile) {
      // do something
      }
      }

      Parameters

      Returns Promise<Entry[]>

    • List the given path synchronously.

      This function will return an array of entries.

      An error will be returned if given path doesn't end with /.

      const list = op.listSync("path/to/dir/");
      for (let entry of list) {
      let meta = op.statSync(entry.path);
      if (meta.isFile) {
      // do something
      }
      }

      With recursive option, you can list recursively.

      const list = op.listSync("path/to/dir/", { recursive: true });
      for (let entry of list) {
      let meta = op.statSync(entry.path);
      if (meta.isFile) {
      // do something
      }
      }

      Parameters

      Returns Entry[]

    • Get a presigned request for read.

      Unit of expires is seconds.

      const req = await op.presignRead(path, parseInt(expires));

      console.log("method: ", req.method);
      console.log("url: ", req.url);
      console.log("headers: ", req.headers);

      Parameters

      • path: string
      • expires: number

      Returns Promise<PresignedRequest>

    • Get a presigned request for stat.

      Unit of expires is seconds.

      const req = await op.presignStat(path, parseInt(expires));

      console.log("method: ", req.method);
      console.log("url: ", req.url);
      console.log("headers: ", req.headers);

      Parameters

      • path: string
      • expires: number

      Returns Promise<PresignedRequest>

    • Get a presigned request for write.

      Unit of expires is seconds.

      const req = await op.presignWrite(path, parseInt(expires));

      console.log("method: ", req.method);
      console.log("url: ", req.url);
      console.log("headers: ", req.headers);

      Parameters

      • path: string
      • expires: number

      Returns Promise<PresignedRequest>

    • Read the whole path into a buffer.

      const buf = await op.read("path/to/file");
      

      Parameters

      • path: string

      Returns Promise<Buffer>

    • Create a reader to read the given path.

      It could be used to read large file in a streaming way.

      Parameters

      • path: string

      Returns Promise<Reader>

    • Read the whole path into a buffer synchronously.

      const buf = op.readSync("path/to/file");
      

      Parameters

      • path: string

      Returns Buffer

    • Remove given paths.

      If underlying services support delete in batch, we will use batch delete instead.

      await op.remove(["abc", "def"]);
      

      Parameters

      • paths: string[]

      Returns Promise<void>

    • Remove the path and all nested dirs and files recursively.

      If underlying services support delete in batch, we will use batch delete instead.

      await op.removeAll("path/to/dir/");
      

      Parameters

      • path: string

      Returns Promise<void>

    • Rename file according to given from and to path.

      It's similar to mv command.

      await op.rename("path/to/file", "path/to/dest");
      

      Parameters

      • from: string
      • to: string

      Returns Promise<void>

    • Rename file according to given from and to path synchronously.

      It's similar to mv command.

      op.renameSync("path/to/file", "path/to/dest");
      

      Parameters

      • from: string
      • to: string

      Returns void

    • Get current path's metadata without cache directly.

      Use stat if you:

      • Want to detect the outside changes of a path.
      • Don’t want to read from cached metadata.

      You may want to use metadata if you are working with entries returned by Lister. It’s highly possible that metadata you want has already been cached.

      const meta = await op.stat("test");
      if (meta.isDir) {
      // do something
      }

      Parameters

      • path: string

      Returns Promise<Metadata>

    • Get current path's metadata without cache directly and synchronously.

      const meta = op.statSync("test");
      if (meta.isDir) {
      // do something
      }

      Parameters

      • path: string

      Returns Metadata

    • Write bytes into a path.

      await op.write("path/to/file", Buffer.from("hello world"));
      // or
      await op.write("path/to/file", "hello world");
      // or
      await op.write("path/to/file", Buffer.from("hello world"), { contentType: "text/plain" });

      Parameters

      • path: string
      • content: string | Buffer
      • Optionaloptions: null | WriteOptions

      Returns Promise<void>

    • Write bytes into a path synchronously.

      op.writeSync("path/to/file", Buffer.from("hello world"));
      // or
      op.writeSync("path/to/file", "hello world");
      // or
      op.writeSync("path/to/file", Buffer.from("hello world"), { contentType: "text/plain" });

      Parameters

      • path: string
      • content: string | Buffer
      • Optionaloptions: null | WriteOptions

      Returns void