From d404597e0b63942ebba6378026081f1ef8dbb72b Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 3 Jun 2016 09:37:09 +0100 Subject: [PATCH] Update FileUploadParser docs. Closes #4167. [ci skip] (#4169) --- docs/api-guide/parsers.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/api-guide/parsers.md b/docs/api-guide/parsers.md index 84fd6e5ac..e1e6d1d65 100644 --- a/docs/api-guide/parsers.md +++ b/docs/api-guide/parsers.md @@ -51,7 +51,7 @@ using the `APIView` class based views. return Response({'received data': request.data}) Or, if you're using the `@api_view` decorator with function based views. - + from rest_framework.decorators import api_view from rest_framework.decorators import parser_classes @@ -93,7 +93,9 @@ You will typically want to use both `FormParser` and `MultiPartParser` together Parses raw file upload content. The `request.data` property will be a dictionary with a single key `'file'` containing the uploaded file. -If the view used with `FileUploadParser` is called with a `filename` URL keyword argument, then that argument will be used as the filename. If it is called without a `filename` URL keyword argument, then the client must set the filename in the `Content-Disposition` HTTP header. For example `Content-Disposition: attachment; filename=upload.jpg`. +If the view used with `FileUploadParser` is called with a `filename` URL keyword argument, then that argument will be used as the filename. + +If it is called without a `filename` URL keyword argument, then the client must set the filename in the `Content-Disposition` HTTP header. For example `Content-Disposition: attachment; filename=upload.jpg`. **.media_type**: `*/*` @@ -105,6 +107,7 @@ If the view used with `FileUploadParser` is called with a `filename` URL keyword ##### Basic usage example: + # views.py class FileUploadView(views.APIView): parser_classes = (FileUploadParser,) @@ -115,6 +118,11 @@ If the view used with `FileUploadParser` is called with a `filename` URL keyword # ... return Response(status=204) + # urls.py + urlpatterns = [ + # ... + url(r'^upload/(?P[^/]+)$', FileUploadView.as_view()) + ] ---