Skip to content

Async operator

The entry class for all public async APIs.

Parameters:

Name Type Description Default
scheme str

The service name that OpenDAL supports.

required
**options any

The options for the service. See the documentation of each service for more details.

{}
Example
1
2
3
import opendal
op = opendal.AsyncOperator("s3", bucket="bucket", region="us-east-1")
await op.write("hello.txt", b"hello world")

copy(source, target) async #

Copy the object from source to target.

Parameters:

Name Type Description Default
source str | Path

The source path.

required
target str | Path

The target path.

required

create_dir(path) async #

Create a directory at the given path.

Parameters:

Name Type Description Default
path str | Path

The path to the directory.

required

delete(path) async #

Delete the object at the given path.

Parameters:

Name Type Description Default
path str | Path

The path to the object.

required

exists(path) async #

Check if the object at the given path exists.

Parameters:

Name Type Description Default
path str | Path

The path to the object.

required

Returns:

Type Description
bool

True if the object exists, False otherwise.

list(path) async #

List the objects at the given path.

Parameters:

Name Type Description Default
path str | Path

The path to the directory.

required

Returns:

Type Description
AsyncIterable[Entry]

An iterable of entries representing the objects in the directory.

open(path, mode) async #

Open a file at the given path for reading or writing.

Parameters:

Name Type Description Default
path str | Path

The path to the file.

required
mode str

The mode to open the file. Can be "rb" or "wb".

required

Returns:

Type Description
AsyncFile

A file-like object that can be used to read or write the file.

Example
1
2
3
4
import opendal
op = opendal.AsyncOperator("s3", bucket="bucket", region="us-east-1")
async with await op.open("hello.txt", "wb") as f:
    await f.write(b"hello world")

presign_delete(path, expire_second) async #

Generate a presigned URL for delete operation.

Parameters:

Name Type Description Default
path str | Path

The path to the object.

required
expire_second int

The expiration time in seconds.

required

Returns:

Type Description
PresignedRequest

A presigned request object.

presign_read(path, expire_second) async #

Generate a presigned URL for read operation.

Parameters:

Name Type Description Default
path str | Path

The path to the object.

required
expire_second int

The expiration time in seconds.

required

Returns:

Type Description
PresignedRequest

A presigned request object.

presign_stat(path, expire_second) async #

Generate a presigned URL for stat operation.

Parameters:

Name Type Description Default
path str | Path

The path to the object.

required
expire_second int

The expiration time in seconds.

required

Returns:

Type Description
PresignedRequest

A presigned request object.

presign_write(path, expire_second) async #

Generate a presigned URL for write operation.

Parameters:

Name Type Description Default
path str | Path

The path to the object.

required
expire_second int

The expiration time in seconds.

required

Returns:

Type Description
PresignedRequest

A presigned request object.

read(path) async #

Read the content of the object at the given path.

Parameters:

Name Type Description Default
path str | Path

The path to the object.

required

Returns:

Type Description
bytes

The content of the object as bytes.

remove_all(path) async #

Remove all objects at the given path.

Parameters:

Name Type Description Default
path str | Path

The path to the directory.

required

rename(source, target) async #

Rename the object from source to target.

Parameters:

Name Type Description Default
source str | Path

The source path.

required
target str | Path

The target path.

required

stat(path) async #

Get the metadata of the object at the given path.

Parameters:

Name Type Description Default
path str | Path

The path to the object.

required

Returns:

Type Description
Metadata

The metadata of the object.

write(path, bs, *, append=..., chunk=..., content_type=..., content_disposition=..., cache_control=...) async #

Write the content to the object at the given path.

Parameters:

Name Type Description Default
path str | Path

The path to the object.

required
bs bytes

The content to write.

required
append bool

Whether to append the content to the object. Defaults to False.

...
chunk int

The chunk size for writing. Defaults to write all.

...
content_type str

The content type of the object. Defaults to None.

...
content_disposition str

The content disposition of the object. Defaults to None.

...
cache_control str

The cache control of the object. Defaults to None.

...