Optional
options: null | Record<string, string>Get current operator(service)'s full capability.
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.
It could be used to read large file in a streaming way.
Create a reader to read the given path synchronously.
It could be used to read large file in a streaming way.
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
}
Get current path's metadata without cache directly and synchronously.
const meta = op.statSync("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 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 | WriterOptionsWrite 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 | WriteOptions
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.