django-ninja: Unable to upload file (always get 'field required' message)
Hi @vitalik, I’m trying to upload a file but it’s always getting a “field required” message.
Handler:
FileParam = File
def file_create(request: HttpRequest,
name: str = FileParam(..., max_length=100),
description: Optional[str] = FileParam(None, max_length=500),
file: UploadedFile = FileParam(...),
folder: Optional[UUID] = FileParam(None)
):
Has anything been missed?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (6 by maintainers)
Commits related to this issue
- fixing mix of form parameters (#134, #162, #201) — committed to vitalik/django-ninja by vitalik 3 years ago
@aprilahijriyan No, currently you have to pass files as arguments
@LexxLuey Found this. I guess PUT does not support multipart…? See Roy T. Fielding’s comment here
Any help would be very much appreciated
In my case, I had to read the file in binary mode :