Request Parameters
- server
- username
- password
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
Return Type
A Client Object
Request Parameters
- repo_id
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.get_repo('09c16e2a-ff1a-4207-99f3-1351c3f1e507')
Return Type
A Library Object
Exception
- Library does not exist.
Request Parameters
None
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.get_repo('09c16e2a-ff1a-4207-99f3-1351c3f1e507')
is_readonly = repo.is_readonly()
Return Type
Boolean
Request Parameters
None
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo_list = client.repos.list_repos()
print(repo_list)
Out >>> [<seafileapi.repo.Repo object at 0x7f1bb0769750>,
<seafileapi.repo.Repo object at 0x7f1bb07693d0>,
<seafileapi.repo.Repo object at 0x7f1bb0769a50>,
<seafileapi.repo.Repo object at 0x7f1bb077cc10>,
<seafileapi.repo.Repo object at 0x7f1bb077cfd0>,
<seafileapi.repo.Repo object at 0x7f1bb077ca10>]
print([repo.name for repo in repo_list])
Out >>> ['alphabox',
'hello',
'Doc',
'obj_test',
'fs_test',
'global']
Return Type
A list of Libraries Object
Request Parameters
- name
- password (default None)
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.create_repo('test_repo')
Return Type
A Library Object
Request Parameters
None
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.get_repo('09c16e2a-ff1a-4207-99f3-1351c3f1e507')
repo.delete()
Return Type
None
Request Parameters
- path
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.get_repo('09c16e2a-ff1a-4207-99f3-1351c3f1e507')
seafdir = repo.get_dir('/root')
print(seafdir.__dict__)
Out >>> {'client': SeafileApiClient[server=http://127.0.0.1:8000, user=admin@admin.com],
'entries': [],
'id': 'c3742dd86004d51c358845fa3178c87e4ab3aa60',
'path': '/root',
'repo': <seafileapi.repo.Repo object at 0x7f2af56b1490>,
'size': 0}
Return Type
A Directory Object
Exception
- Directory does not exist.
Request Parameters
- force_refresh (default False)
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.get_repo('09c16e2a-ff1a-4207-99f3-1351c3f1e507')
seafdir = repo.get_dir('/root')
lst = seafdir.ls(force_refresh=True)
print(lst)
Out >>> [SeafDir[repo=01ccc4,path=/Seahub/6.1.x,entries=14],
SeafDir[repo=01ccc4,path=/Seahub/6.2.2-pro,entries=1],
SeafDir[repo=01ccc4,path=/Seahub/6.2.3,entries=15],
SeafDir[repo=01ccc4,path=/Seahub/6.2.x,entries=5],
SeafFile[repo=01ccc4,path=/Seahub/.DS_Store,size=6148],
SeafFile[repo=01ccc4,path=/Seahub/error.md,size=127],
SeafFile[repo=01ccc4,path=/Seahub/preview-research.md,size=1030]]
print([dirent.name for dirent in lst])
Out >>> ['6.1.x',
'6.2.2-pro',
'6.2.3',
'6.2.x',
'.DS_Store',
'error.md',
'preview-research.md']
Return Type
List of Directory and File
Request Parameters
- name
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.get_repo('09c16e2a-ff1a-4207-99f3-1351c3f1e507')
seafdir = repo.get_dir('/root')
new_dir = seafdir.mkdir('tmp_dir')
Return Type
A Directory Object of new directory
Request Parameters
None
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.get_repo('09c16e2a-ff1a-4207-99f3-1351c3f1e507')
seafdir = repo.get_dir('/root')
seafdir.delete()
Return Type
A Response Instance
Request Parameters
- path
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.get_repo('09c16e2a-ff1a-4207-99f3-1351c3f1e507')
seaffile = repo.get_file('/root/test.md')
print(seaffile.__dict__)
Out >>> {'client': SeafileApiClient[server=http://127.0.0.1:8000, user=admin@admin.com],
'id': '0000000000000000000000000000000000000000',
'path': '/root/test.md',
'repo': <seafileapi.repo.Repo object at 0x7f2af56b1490>,
'size': 0}
Return Type
A File Object
Exception
- File does not exist.
Request Parameters
None
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.get_repo('09c16e2a-ff1a-4207-99f3-1351c3f1e507')
seaffile = repo.get_file('/root/test.md')
content = seaffile.get_content()
Return Type
File Content
Request Parameters
- name
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.get_repo('09c16e2a-ff1a-4207-99f3-1351c3f1e507')
seafdir = repo.get_dir('/root')
new_file = seafdir.create_empty_file('tmp_file.md')
Return Type
A File Object of new empty file
Request Parameters
- filepath
- name (default None, default use local file name)
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.get_repo('09c16e2a-ff1a-4207-99f3-1351c3f1e507')
seafdir = repo.get_dir('/root')
file = seafdir.upload_local_file('/home/ubuntu/env.md')
Return Type
A File Object of upload file
Exception
- Local file does not exist.
Request Parameters
None
Sample Case
import seafileapi
client = seafileapi.connect('http://127.0.0.1:8000', '[email protected]', 'password')
repo = client.repos.get_repo('09c16e2a-ff1a-4207-99f3-1351c3f1e507')
seaffile = repo.get_file('/root/test.md')
seaffile.delete()
Return Type
A Response Instance