Skip to content

Batch Operations ​

OxiCloud exposes batch endpoints for bulk file and folder operations under /api/batch. Batch requests reduce round-trips, run concurrently behind a semaphore, and return per-item success and failure details instead of aborting on the first error.

What You Can Do ​

File operations ​

MethodPathDescription
POST/api/batch/files/moveMove multiple files into a target folder
POST/api/batch/files/copyCopy multiple files into a target folder
POST/api/batch/files/deleteDelete multiple files
POST/api/batch/files/getFetch metadata for multiple files

Folder operations ​

MethodPathDescription
POST/api/batch/folders/deleteDelete multiple folders
POST/api/batch/folders/createCreate multiple folders
POST/api/batch/folders/getFetch metadata for multiple folders
POST/api/batch/folders/moveMove multiple folders

Additional batch endpoints ​

MethodPathDescription
POST/api/batch/trashTrash multiple items in one request
POST/api/batch/downloadBuild a batch download

Request Shapes ​

File move or copy ​

json
{
  "file_ids": ["id-1", "id-2", "id-3"],
  "target_folder_id": "folder-abc"
}

Folder delete ​

json
{
  "folder_ids": ["folder-1", "folder-2"],
  "recursive": true
}

Folder create ​

json
{
  "folders": [
    { "name": "Documents", "parent_id": null },
    { "name": "Photos", "parent_id": "folder-abc" }
  ]
}

Response Format ​

All batch endpoints return the same envelope:

json
{
  "successful": [
    { "id": "id-1" }
  ],
  "failed": [
    { "id": "bad-id", "error": "File not found" }
  ],
  "stats": {
    "total": 5,
    "successful": 4,
    "failed": 1,
    "execution_time_ms": 245
  }
}

Status codes ​

CodeMeaning
200 OK or 201 CreatedEvery operation succeeded
206 Partial ContentSome operations succeeded and some failed
400 Bad RequestEvery operation failed

Concurrency Model ​

Batch work is coordinated by BatchOperationService and a tokio::sync::Semaphore. By default, OxiCloud caps concurrent work with max_concurrent_files = 10 so large batches do not starve the rest of the application.

Individual failures are collected in the failed array. One bad item does not cancel the whole request unless the batch cannot start at all.

Example ​

bash
# Move three files into a folder
curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"file_ids":["id-1","id-2","id-3"],"target_folder_id":"folder-abc"}' \
  "https://oxicloud.example.com/api/batch/files/move"

# Delete multiple folders recursively
curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"folder_ids":["old-1","old-2"],"recursive":true}' \
  "https://oxicloud.example.com/api/batch/folders/delete"

Released under the MIT License.