aioseaweedfs

Documentation
Login

Filer Usage

instantiate

filer = aioseaweedfs.Filer("http://localhost:8888")

If your proxy server uses HTTP basic authentication:

filer = aioseaweedfs.Filer("http://localhost:8888", basic_auth=("username", "password"))

post files

await filer.post(
    "/path/to/file.txt",
    "hello world", 
    content_type="text/plain"
)

File content can be str, bytes, or open file.

get files

content = await filer.get("/path/to/file.txt")

content is bytes

save to local file

content = await filer.download("/path/to/file.txt", "/tmp/myfile.txt")

delete

await filer.delete("/path/to/file.txt")

move

await filer.mv("/path/to/file.txt", "/path/to/new/file.txt")

list

entries = await filer.ls("/path/to/")

walk

async for dirname, dirs, files in filer.walk("/"):
    print(files)

Master Usage

async with Master("http://localhost:9333") as master:
    volume, fids = await master.get_assign_key()
    # fids is a list of file ids

Use the volume object to post/get/delete files


master = Master("http://localhost:9333")
volume = await master.get_volume("12")
volume = await master.get_volume("159,02de536cff93")

Volume Usage

await volume.post(file_id, "content", content_type="text/plain")
content = await volume.get(file_id)
await volume.delete(file_id)

Source

The Source code is very readable.