Append bytes into path.
await op.append("path/to/file", Buffer.from("hello world"));
// or
await op.append("path/to/file", "hello world");
Get current operator(service)'s full capability.
Check if this operator can work correctly.
We will send a list
request to path and return any errors we met.
await op.check();
Copy file according to given from
and to
path.
await op.copy("path/to/file", "path/to/dest");
Copy file according to given from
and to
path synchronously.
op.copySync("path/to/file", "path/to/dest");
Add a layer to this operator.
List 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
}
}
Optional
options: null | ListOptionsList given path synchronously.
This function will return a 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
}
}
Optional
options: null | ListOptionsGet 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);
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);
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);
Create a reader to read the given path synchronously.
It could be used to read large file in a streaming way.
Rename file according to given from
and to
path.
It's similar to mv
command.
await op.rename("path/to/file", "path/to/dest");
Rename file according to given from
and to
path synchronously.
It's similar to mv
command.
op.renameSync("path/to/file", "path/to/dest");
Get current path's metadata without cache directly.
Use stat if you:
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
}
Write bytes into path.
await op.write("path/to/file", Buffer.from("hello world"));
// or
await op.write("path/to/file", "hello world");
Write bytes into path synchronously.
op.writeSync("path/to/file", Buffer.from("hello world"));
// or
op.writeSync("path/to/file", "hello world");
Write multiple bytes into path synchronously.
It could be used to write large file in a streaming way.
Copyright © 2022-2024, The Apache Software Foundation. Apache OpenDAL, OpenDAL, and Apache are either registered trademarks or trademarks of the Apache Software Foundation.
See
For a detailed definition of scheme, see https://opendal.apache.org/docs/category/services