-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e10bbf
commit dba8b15
Showing
1 changed file
with
48 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,6 +147,10 @@ The newly created repo object is returned: | |
seafile_api.delete_repo(repo_id) | ||
``` | ||
|
||
**Parameters:** | ||
|
||
* repo_id: unique identifier of a library | ||
|
||
**Example:** | ||
|
||
```python | ||
|
@@ -158,23 +162,27 @@ seafile_api.delete_repo(repo_id) | |
|
||
## File / Dir operation | ||
|
||
In the previous section, we talked about how to authorize a repo, and once authorized, you can manipulate the files and directories inside based on the functions in repo object. | ||
You can use Repo object to manipulate files and directories. | ||
|
||
### List dir | ||
|
||
List the items inside a specific directory of a path | ||
|
||
```python | ||
repo.list_dir(dir_path = '/') | ||
``` | ||
|
||
Return the list of items in plain objects showed in a specific dir. | ||
|
||
**Parameters:** | ||
|
||
* dir_path: a parent path inside of which the items you want to list. | ||
|
||
**Example:** | ||
|
||
```python | ||
repo.list_dir('/root') | ||
repo.list_dir('/root') | ||
``` | ||
|
||
And then the items returned as: | ||
A list of dir items in plain objects is returned: | ||
|
||
``` | ||
[{ | ||
|
@@ -183,18 +191,18 @@ And then the items returned as: | |
'name': 'auto-upload', | ||
'mtime': '2023-03-14T14:36:49+08:00', | ||
'permission': 'rw', | ||
'parent_dir': '/images/', | ||
'parent_dir': '/root', | ||
'starred': False | ||
}, { | ||
'type': 'file', | ||
'id': '9669d47f26f709148e1b36917a90b9eecb167167', | ||
'name': '6613.txt', | ||
'mtime': '2020-12-26T10:14:52+08:00', | ||
'permission': 'rw', | ||
'parent_dir': '/images/', | ||
'parent_dir': '/root', | ||
'size': 14, | ||
'modifier_email': '[email protected]', | ||
'modifier_name': '冉继伟', | ||
'modifier_name': 'Jiwei', | ||
'modifier_contact_email': '[email protected]', | ||
'is_locked': False, | ||
'lock_time': 0, | ||
|
@@ -206,23 +214,25 @@ And then the items returned as: | |
}, ...] | ||
``` | ||
|
||
|
||
|
||
### Create a dir | ||
|
||
```python | ||
repo.create_dir(path) | ||
``` | ||
|
||
* path, the directory you want to create | ||
Create a directory and return a plain object. | ||
|
||
**Parameters:** | ||
|
||
* path: a path with a new dir you want to create | ||
|
||
**Example:** | ||
|
||
```python | ||
repo.create_dir('/A new') | ||
``` | ||
|
||
And then the result returned as: | ||
A dir in plain object is returned: | ||
|
||
``` | ||
{ | ||
|
@@ -235,21 +245,25 @@ And then the result returned as: | |
} | ||
``` | ||
|
||
|
||
|
||
### Rename a dir | ||
|
||
```python | ||
repo.rename_dir(path, new_name) | ||
``` | ||
|
||
Change the dir name and return a plain object. | ||
|
||
**Parameters:** | ||
|
||
* path: a path with old dir name. | ||
|
||
**Example:** | ||
|
||
```python | ||
repo.rename_dir('/A new', 'new file') | ||
``` | ||
|
||
And then the result returned as: | ||
A dir in plain object is returned: | ||
|
||
``` | ||
{ | ||
|
@@ -262,14 +276,14 @@ And then the result returned as: | |
} | ||
``` | ||
|
||
|
||
|
||
### Delete dir | ||
|
||
```python | ||
repo.delete_dir(path) | ||
``` | ||
|
||
A dir in a specific path will be deleted. | ||
|
||
**Example:** | ||
|
||
```python | ||
|
@@ -280,19 +294,19 @@ repo.delete_dir('/new file') | |
|
||
### Get a file | ||
|
||
Get details of a file | ||
|
||
```python | ||
repo.get_file(path) | ||
``` | ||
|
||
Get details of a file and return a plain object | ||
|
||
**Example** | ||
|
||
```python | ||
repo.get_file('/file/readme.txt') | ||
``` | ||
|
||
And then the result returned as: | ||
A file in plain object is returned: | ||
|
||
``` | ||
{ | ||
|
@@ -308,21 +322,21 @@ And then the result returned as: | |
} | ||
``` | ||
|
||
|
||
|
||
### Create a file | ||
|
||
```python | ||
repo.create_file(path) | ||
``` | ||
|
||
Create a file and return a plain object. | ||
|
||
**Example** | ||
|
||
```python | ||
repo.create('/file/d.txt') | ||
``` | ||
|
||
And then the result returned as: | ||
A file in plain object is returned: | ||
|
||
``` | ||
{ | ||
|
@@ -338,27 +352,31 @@ And then the result returned as: | |
} | ||
``` | ||
|
||
|
||
|
||
### Rename a file | ||
|
||
```python | ||
repo.rename_file(path, new_name) | ||
``` | ||
|
||
Change the file name and return a plain object. | ||
|
||
**Parameters:** | ||
|
||
* path: a path with old file name. | ||
|
||
**Example** | ||
|
||
```python | ||
repo.rename_file('/file/readme.txt', 'readme1.txt') | ||
``` | ||
|
||
And then the result returned as: | ||
A file in plain object is returned: | ||
|
||
``` | ||
{ | ||
'type': 'file', | ||
'repo_id': '83066b00-67ef-4068-b738-7a7381558d1b', | ||
'parent_dir': '/images', | ||
'parent_dir': '/file', | ||
'obj_name': 'readme1.txt', | ||
'obj_id': '0000000000000000000000000000000000000000', | ||
'size': 0, | ||
|
@@ -368,29 +386,27 @@ And then the result returned as: | |
} | ||
``` | ||
|
||
|
||
|
||
### Delete a file | ||
|
||
```python | ||
repo.delete_file(path) | ||
``` | ||
|
||
A file in a specific path will be deleted. | ||
|
||
**Example** | ||
|
||
```python | ||
repo.delete_file('/file/readme.txt') | ||
``` | ||
|
||
|
||
|
||
### Get repo details | ||
|
||
```python | ||
repo.get_repo_details() | ||
``` | ||
|
||
And then the result returned as: | ||
A repo info in plain object is returned: | ||
|
||
``` | ||
{ | ||
|