Get current operator(service)'s full capability.
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();
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 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
}
}
Optional
options: null | ListOptionsList 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
}
}
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 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" });
Optional
options: null | WriteOptionsWrite 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" });
Optional
options: null | WriteOptionsWrite multiple bytes into a path.
It could be used to write large file in a streaming way.
Optional
options: null | WriterOptionsWrite multiple bytes into a path synchronously.
It could be used to write large file in a streaming way.
Optional
options: null | WriterOptionsCopyright © 2022-2024, The Apache Software Foundation. Apache OpenDAL, OpenDAL, and Apache are either registered trademarks or trademarks of the Apache Software Foundation.
See
For the full list of scheme, see https://docs.rs/opendal/latest/opendal/services/index.html And the options, please refer to the documentation of the corresponding service for the corresponding parameters. Note that the current options key is snake_case.