HumanSignal / HumanSignal/label-studio

Upload multiple direct files via API

Open
#4,484 4 comments 0 reactions 2 assignees Assigned to @Raven888888 View on GitHub
community:needs-information community:reviewed
Dominant language
TypeScript
Stars
28.3k
Forks
3.7k
Avg merge
14h
Merged PRs (30d)
15

Description

**Describe the bug**
For a single direct file upload to a project, it is working perfectly fine.
However, when I upload multiple direct files to the same project, it does not support it.

**To Reproduce**
1. Create a project with template more than 1 data keys
```



















```

2. Use API to upload direct files
```python
files = {
'media': open(filename, 'rb')
}
requests.post(self.ls_url + 'api/projects/' + project_id + '/import?commit_to_project=false', files=files, headers={'Authorization': 'Token ' + self.token})
```

3. Hit error
```
{
"id": "5ca95a39-4909-48a5-b368-54ee24b37241",
"status_code": 400,
"version": "1.8.0",
"detail": "Validation error",
"exc_info": null,
"validation_errors": {
"non_field_errors": [
"Failed to parse input file upload/1906/fb0ecb39-cam_depthmap_189.png: [ErrorDetail(string='Your label config has more than one data key and direct file upload supports only one data key. To import data with multiple data keys, use a JSON or CSV file.', code='invalid')]"
]
}
}
```

4. I also try doing this, but also fail
```python
files = {
'media': open(filename, 'rb'),
'media2': open(filename2, 'rb'),
'media3': open(filename3, 'rb')
}
requests.post(self.ls_url + 'api/projects/' + project_id + '/import?commit_to_project=false', files=files, headers={'Authorization': 'Token ' + self.token})
```

**Expected behavior**
Able to do multiple direct files upload via API.

**Environment (please complete the following information):**
- OS: Ubuntu 20.04
- Label Studio Version: 1.8.0 (docker setup)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.