removing filename from put parameter list did the trick

On Thursday, June 2, 2016 at 8:54:44 PM UTC+2, Pawel Jasinski wrote:
>
> Hi,
>
> I suspect it is some configuration problem on my side, but I can not 
> figure it out. 
> I am trying to use the raw file upload as described here 
> http://www.django-rest-framework.org/api-guide/parsers/#fileuploadparser
> It appears as if FileUploadParser did not exist.
> The test:
>
> curl -v -u user:pass http://d2:8000/uploadapp/uploadfile --upload-file 
> 1.jpg --header "Content-Disposition: attachment; filename=1.jpg"  --header 
> "Content-type: application/jpeg"
>
> The exception: 
> Internal Server Error: /uploadapp/uploadfile
> Traceback (most recent call last):
>   File 
> "/opt/venv/p3-django/lib/python3.4/site-packages/django/core/handlers/base.py",
>  
> line 149, in get_response
>     response = self.process_exception_by_middleware(e, request)
>   File 
> "/opt/venv/p3-django/lib/python3.4/site-packages/django/core/handlers/base.py",
>  
> line 147, in get_response
>     response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File 
> "/opt/venv/p3-django/lib/python3.4/site-packages/django/views/decorators/csrf.py",
>  
> line 58, in wrapped_view
>     return view_func(*args, **kwargs)
>   File 
> "/opt/venv/p3-django/lib/python3.4/site-packages/django/views/generic/base.py",
>  
> line 68, in view
>     return self.dispatch(request, *args, **kwargs)
>   File 
> "/opt/venv/p3-django/lib/python3.4/site-packages/rest_framework/views.py", 
> line 468, in dispatch
>     response = self.handle_exception(exc)
>   File 
> "/opt/venv/p3-django/lib/python3.4/site-packages/rest_framework/views.py", 
> line 465, in dispatch
>     response = handler(request, *args, **kwargs)
> TypeError: put() missing 1 required positional argument: 'filename'
> [01/Jun/2016 02:57:58] "PUT /uploadapp/uploadfile HTTP/1.1" 500 74097
>
> The output of curl:
>
> * Connected to d2 (172.16.175.16) port 8000 (#0)
> * Server auth using Basic with user 'rejap'
> > PUT /uploadapp/uploadfile HTTP/1.1
> > Authorization: Basic xxxxx
> > User-Agent: curl/7.35.0
> > Host: d2:8000
> > Accept: */*
> > Content-Disposition: attachment; filename=upload.jpg
> > Content-type: application/jpeg
> > Content-Length: 2735263
> > Expect: 100-continue
> > 
> * HTTP 1.0, assume close after body
> < HTTP/1.0 500 Internal Server Error
> < Date: Wed, 01 Jun 2016 02:57:58 GMT
> < Server: WSGIServer/0.2 CPython/3.4.3
> < Content-Type: text/html
> < Vary: Cookie
> < X-Frame-Options: SAMEORIGIN
> < 
>
>
> the url.py of my app:
>
> urlpatterns = [ 
>    url(r'^uploadfile$', FileUploadView.as_view(), name='upload-raw-file'),
> ]
>
> the view of my app:
>
> class FileUploadView(APIView):
>     parser_classes = (FileUploadParser,)
>
>     def put(self, request, filename, format=None):
>         file_obj = request.data['file']
>         # ...
>         # do some stuff with uploaded file
>         # ...
>         return Response(status=204)
>
>
>
> --pawel
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to