2017-05-19 1 views
0

Ich Beiträge Anfragen mit Curl mit diesem zu machen, und noch einfacher als das:immer leer Post-Anforderung mit Django1.10 + Nginx + Betreuer + Gunicorn

curl -u usr:pwd -H "Content-Type: multipart/form-data" -i --form "[email protected]/path/to/myfile/myfile.zip" -X POST http://midominio.co/api/mypostrequest/ 

aber ich bin immer immer eine leere Körper, das, was ich bekomme:

{ 
'session': <django.contrib.sessions.backends.db.SessionStore object at 0x7f118e502b90>, 
'_post': <QueryDict: {}>, 
'content_params': {'boundary': '------------------------axxxxxxxxx'}, 
'_post_parse_error': False, 
'_messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7f118e502d90>, 
'resolver_match': ResolverMatch(func=piston.resource.Resource, args=(), kwargs={}, url_name=None, app_names=[], namespaces=[]), 
'GET': <QueryDict: {}>, 
'_stream': <django.core.handlers.wsgi.LimitedStream object at 0x7f118e502b50>, 
'COOKIES': {}, 
'_files': <MultiValueDict: {}>, 
'_read_started': False, 
'META': {'HTTP_AUTHORIZATION': 'Basic Y2FpbjpjYWlu', 
'SERVER_SOFTWARE': 'gunicorn/19.7.1', 
'SCRIPT_NAME': u'', 
'REQUEST_METHOD': 'POST', 
'PATH_INFO': u'/api/mypostrequest/', 
'SERVER_PROTOCOL': 'HTTP/1.0', 
'QUERY_STRING': '', 
'CONTENT_LENGTH': '180', 
'HTTP_USER_AGENT': 'curl/7.51.0', 
'HTTP_CONNECTION': 'close', 
'SERVER_NAME': 'midominio.co', 
'REMOTE_ADDR': '', 
'wsgi.url_scheme': 'http', 
'SERVER_PORT': '80', 
'wsgi.input': <gunicorn.http.body.Body object at 0x7f118e5029d0>, 
'HTTP_HOST': 'midominio.co', 
'wsgi.multithread': False, 
'HTTP_ACCEPT': '*/*', 
'wsgi.version': (1, 0), 
'RAW_URI': '/api/mypostrequest/', 
'wsgi.run_once': False, 
'wsgi.errors': <gunicorn.http.wsgi.WSGIErrorsWrapper object at 0x7f118e502950>, 
'wsgi.multiprocess': True, 
'gunicorn.socket': <socket._socketobject object at 0x7f118e4f6de0>, 
'CONTENT_TYPE': 'multipart/form-data; boundary=------------------------axxxxxxxxx', 
'HTTP_X_FORWARDED_FOR': '186.00.00.000', 
'wsgi.file_wrapper': <class 'gunicorn.http.wsgi.FileWrapper'>}, 
'environ': {'HTTP_AUTHORIZATION': 'Basic Y2FpbjpjYWlu', 
'SERVER_SOFTWARE': 'gunicorn/19.7.1', 
'SCRIPT_NAME': u'', 
'REQUEST_METHOD': 'POST', 
'PATH_INFO': u'/api/mypostrequest/', 
'SERVER_PROTOCOL': 'HTTP/1.0', 
'QUERY_STRING': '', 
'CONTENT_LENGTH': '180', 
'HTTP_USER_AGENT': 'curl/7.51.0', 
'HTTP_CONNECTION': 'close', 
'SERVER_NAME': 'midominio.co', 
'REMOTE_ADDR': '', 
'wsgi.url_scheme': 'http', 
'SERVER_PORT': '80', 
'wsgi.input': <gunicorn.http.body.Body object at 0x7f118e5029d0>, 
'HTTP_HOST': 'midominio.co', 
'wsgi.multithread': False, 
'HTTP_ACCEPT': '*/*', 
'wsgi.version': (1, 0), 
'RAW_URI': '/api/mypostrequest/', 
'wsgi.run_once': False, 
'wsgi.errors': <gunicorn.http.wsgi.WSGIErrorsWrapper object at 0x7f118e502950>, 
'wsgi.multiprocess': True, 
'gunicorn.socket': <socket._socketobject object at 0x7f118e4f6de0>, 
'CONTENT_TYPE': 'multipart/form-data; boundary=------------------------axxxxxxxxx', 
'HTTP_X_FORWARDED_FOR': '186.00.00.000', 
'wsgi.file_wrapper': <class 'gunicorn.http.wsgi.FileWrapper'>}, 
'path_info': u'/api/mypostrequest/', 
'content_type': 'multipart/form-data; boundary=------------------------axxxxxxxxx', 
'path': u'/api/mypostrequest/', 
'data': <QueryDict: {}>, 
'method': 'POST', 
'user': <User: cain> 

}

ich die Standard-nginx Konfiguration bin mit, ich habe auch eine Web-Version dieses Teil mit einem „Upload-Button“ und alles funktioniert prima Es gibt keinen Fehler Oder in den .log-Dateien von Nginx oder Supervisor und der Django-Installation ist in Ordnung, irgendwelche Ideen?

dank
+0

'--form" file = @/Pfad/zu/meinedatei/meinedatei.zip "' – e4c5

+0

@ e4c5 war ein Fehler, als ich hier schrieb, habe ich gerade behoben – LaBE

+0

hast du es mit einem einfachen HTML-Formular versucht? – e4c5

Antwort

0

Ich war ein Fehler versucht, dies als eine normale Anfrage zu nehmen, ist dies ein WSGIRequest so dass heißt, es anders verarbeitet werden, muss ich dieses Problem gelöst mit, ich diese Hilfe hoffe jemand anderes:

environ = request.environ 
    form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) 
    f = form['file'].file 
Verwandte Themen