seafile-web-api-2.1

Batch Operation with Multiple Files/Directories

Synchronized Operations

Batch Copy Items Synchronously

POST http://192.168.1.113:8000/api/v2.1/repos/sync-batch-copy-item/

Request parameters

Content type of parameter must be application/json and passed through POST request’s body.

{
    "src_repo_id":"7460f7ac-a0ff-4585-8906-bb5a57d2e118",
    "src_parent_dir":"/a/b/c/",
    "src_dirents":["1.md", "2.md"],
    
    "dst_repo_id":"a3fa768d-0f00-4343-8b8d-07b4077881db",
    "dst_parent_dir":"/x/y/",
}

Sample request

curl -d '{"src_repo_id":"b3e045da-0c2c-4e68-be15-7480f7aac717", "src_parent_dir":"/", "dst_parent_dir":"/", "dst_repo_id":"fb5b4682-a761-4a9d-810c-ebf72ac2926e", "src_dirents":["123", "test.md"]}' -H 'Authorization: Token 825d6877dc3474d952b1f5b0654aeaeb90c48281' -H 'Accept: application/json; charset=utf-8; indent=4' -H 'Content-Type: application/json' "http://127.0.0.1:8000/api/v2.1/repos/sync-batch-copy-item/"

Sample response

{
    "success": "true"
}

Errors

Batch Move Items Synchronously

POST http://192.168.1.113:8000/api/v2.1/repos/sync-batch-move-item/

Request parameters

Content type of parameter must be application/json and passed through POST request’s body.

{
    "src_repo_id":"7460f7ac-a0ff-4585-8906-bb5a57d2e118",
    "src_parent_dir":"/a/b/c/",
    "src_dirents":["1.md", "2.md"],
    
    "dst_repo_id":"a3fa768d-0f00-4343-8b8d-07b4077881db",
    "dst_parent_dir":"/x/y/",
}

Sample request

curl -d '{"src_repo_id":"b3e045da-0c2c-4e68-be15-7480f7aac717", "src_parent_dir":"/", "dst_parent_dir":"/", "dst_repo_id":"fb5b4682-a761-4a9d-810c-ebf72ac2926e", "src_dirents":["123", "test.md"]}' -H 'Authorization: Token 825d6877dc3474d952b1f5b0654aeaeb90c48281' -H 'Accept: application/json; charset=utf-8; indent=4' -H 'Content-Type: application/json' "http://127.0.0.1:8000/api/v2.1/repos/sync-batch-move-item/"

Sample response

{
    "success": "true"
}

Errors

Delete

DELETE https://cloud.seafile.com/api/v2.1/repos/batch-delete-item/

Request parameters

Content type of parameter must be application/json and passed through DELETE request’s body.

{
    "repo_id":"7460f7ac-a0ff-4585-8906-bb5a57d2e118",
    "parent_dir":"/a/b/c/",
    "dirents":["1.md", "2.md"],
}

Sample request

curl -X DELETE -d '{"repo_id":"b3e045da-0c2c-4e68-be15-7480f7aac717", "parent_dir":"/", "dirents":["123", "test.md"]}' -H 'Authorization: Token 825d6877dc3474d952b1f5b0654aeaeb90c48281' -H 'Accept: application/json; charset=utf-8; indent=4' -H 'Content-Type: application/json' "http://127.0.0.1:8000/api/v2.1/repos/batch-delete-item/"

Sample response

{
    "success": true
}

Errors

Asynchronized Operations

Batch Copy Items Asynchronously

POST http://192.168.1.113:8000/api/v2.1/repos/async-batch-copy-item/

Request parameters

Content type of parameter must be application/json and passed through POST request’s body.

{
    "src_repo_id":"7460f7ac-a0ff-4585-8906-bb5a57d2e118",
    "src_parent_dir":"/a/b/c/",
    "src_dirents":["1.md", "2.md"],
    
    "dst_repo_id":"a3fa768d-0f00-4343-8b8d-07b4077881db",
    "dst_parent_dir":"/x/y/",
}

Sample request

curl -d '{"src_repo_id":"b3e045da-0c2c-4e68-be15-7480f7aac717", "src_parent_dir":"/", "dst_parent_dir":"/", "dst_repo_id":"fb5b4682-a761-4a9d-810c-ebf72ac2926e", "src_dirents":["123", "test.md"]}' -H 'Authorization: Token 825d6877dc3474d952b1f5b0654aeaeb90c48281' -H 'Accept: application/json; charset=utf-8; indent=4' -H 'Content-Type: application/json' "http://127.0.0.1:8000/api/v2.1/repos/async-batch-copy-item/"

Sample response

Note: if you copy files/folders in the same library, task_id in response will be empty string.

{
    "task_id": "3ebdbbcb-3f43-459b-87ee-6c89c192a810"
}

Errors

Batch Move Items Asynchronously

POST http://192.168.1.113:8000/api/v2.1/repos/async-batch-move-item/

Request parameters

Content type of parameter must be application/json and passed through POST request’s body.

{
    "src_repo_id":"7460f7ac-a0ff-4585-8906-bb5a57d2e118",
    "src_parent_dir":"/a/b/c/",
    "src_dirents":["1.md", "2.md"],
    
    "dst_repo_id":"a3fa768d-0f00-4343-8b8d-07b4077881db",
    "dst_parent_dir":"/x/y/",
}

Sample request

curl -d '{"src_repo_id":"b3e045da-0c2c-4e68-be15-7480f7aac717", "src_parent_dir":"/", "dst_parent_dir":"/", "dst_repo_id":"fb5b4682-a761-4a9d-810c-ebf72ac2926e", "src_dirents":["123", "test.md"]}' -H 'Authorization: Token 825d6877dc3474d952b1f5b0654aeaeb90c48281' -H 'Accept: application/json; charset=utf-8; indent=4' -H 'Content-Type: application/json' "http://127.0.0.1:8000/api/v2.1/repos/async-batch-move-item/"

Sample response

Note: if you move files/folders in the same library, task_id in response will be empty string.

{
    "task_id": "d40df789-5e0b-4007-b590-203a04d6cb90"
}

Errors

Query Async Operation Progress

GET https://cloud.seafile.com/api/v2.1/query-copy-move-progress/

Request parameters

Sample request

curl -H 'Authorization: Token ae265ae599a29c238ca25fb63087859798d5f55d' -H 'Accept: application/json; charset=utf-8; indent=4' 'https://cloud.seafile.com/api/v2.1/query-copy-move-progress/?task_id=d1ca2b8c-8ab8-4dd4-8ad7-842130764484'

Sample response

{
    "failed_reason": "",
    "failed": false,
    "successful": true,
    "canceled": false,
    "done": 1,
    "total": 1
}

Errors

Cancel Async operation

DELETE https://cloud.seafile.com/api/v2.1/copy-move-task/

Request parameters

Sample request

curl -X DELETE -d "task_id=d1ca2b8c-8ab8-4dd4-8ad7-842130764484" -H 'Authorization: Token ae265ae599a29c238ca25fb63087859798d5f55d' -H 'Accept: application/json; charset=utf-8; indent=4' 'https://cloud.seafile.com/api/v2.1/copy-move-task/'

Sample response

{
    "success": true
}

Errors

Download Multiple Items

Perform the following two steps to download multiple files and directories.

Get Task Token

POST https://cloud.seafile.com/api/v2.1/repos/{repo-id}/zip-task/

Request parameters

Sample request

one dirent

curl -d 'parent_dir=/my_folder&dirents=pdfs' -H 'Authorization: Token 0eb24ce5db35a31f70171eca2f760f03f59fa09a' -H 'Accept: application/json; charset=utf-8; indent=4' "https://cloud.seafile.com/api/v2.1/repos/7460f7ac-a0ff-4585-8906-bb5a57d2e118/zip-task/"

mutiple dirents

curl -d 'parent_dir=/my_folder&dirents=pdfs&dirents=docs&dirents=images' -H 'Authorization: Token 0eb24ce5db35a31f70171eca2f760f03f59fa09a' -H 'Accept: application/json; charset=utf-8; indent=4' "https://cloud.seafile.com/api/v2.1/repos/7460f7ac-a0ff-4585-8906-bb5a57d2e118/zip-task/"

Sample response

{
    "zip_token": "b2272645-35ee-44ce-8f68-07c022107015"
}

Errors

Query Task Progress

Use the token returned from previous request to check if task progress finished.

GET https://cloud.seafile.com/api/v2.1/query-zip-progress/?token={token}

Sample request

curl -H 'Authorization: Token 0eb24ce5db35a31f70171eca2f760f03f59fa09a' -H 'Accept: application/json; charset=utf-8; indent=4' "https://cloud.seafile.com/api/v2.1/query-zip-progress/?token=b2272645-35ee-44ce-8f68-07c022107015"

Sample response

If zipped is equal to total, means task finished.

{
    "zipped":2,
    "total":2
}

Errors

After the task finished, you can access the zipped items with URL like:

FILE_SERVER_ROOT/zip/{zip_token}

For example, https://cloud.seafile.com/seafhttp/zip/b2272645-35ee-44ce-8f68-07c022107015 is the final URL in this case.