How can I send multipart/form-data that contains json object and image file via curl? And how can I treat it with Django Rest Framework?
curl, django, django-rest-framework, python
Solution
Thanks xjtian - link that you pasted in comment + some researches make solution. So:
If you want sending json data + file - send two requests. First will create object on backend and give id to app. Second will update object with file using gived id. More info there.
If you don't care about data types - send request via "multipart/form-data".
Thanks to all for answers, you realy helps, but I think this one is more appropriate for REST architecture.
Problem
For example I tried that command via terminal: ``` curl -F "profileImage=@/home/user/image.jpg" -F "{'firstName':'hello'};type=application/json" http://127.0.0.1:8000/api/v1/signup/ ``` Then I received the `request` object like that: ``` print request.FILES # <MultiValueDict: {u'profileImage': [<InMemoryUploadedFile: image.jpg (image/jpeg)>]}> print request.DATA # <QueryDict: {u"{'firstName':'hello'};content-type": [u'application/json']}> ``` The image is ok, but QueryDict is not represented correctly - all JSON file is a key and content-type is a value. In Django use these parsers: ``` parser_classes = (MultiPartParser, FormParser, JSONParser,) ``` I necessary need to send text data via JSON structure .