title: Serializing uploaded file data Django Rest Framework
body: <p>I am trying to get a file upload system working in Django Rest Framework. </p>
  
  <p>The files I want to upload are .gpx files which are custom xml files. I don't want to store the files in the database, instead I want to extract information from them and then input this into my model. </p>
  
  <p>I have a function that takes a temp file and then extracts the info and then creates the model elements as needed. What I'm looking to do is perform some checks on the file before it is uploaded and passed to this function. </p>
  
  <p>How should I do this?</p>
  
  <p>The file upload is currently done as in the documentation (see below), which a generic APIView and a put command. This works perfectly, I just want to know what the best way is to check this file's validity before upload.</p>
  
  <p>views.py</p>
  
  <pre><code>class FileUploadView(views.APIView):
      parser_classes = (FileUploadParser, )
  
      def put(self, request, filename, format=None):
          up_file = request.data['file']
  
          SaveGPXtoModel(up_file, request.user)
  
          return Response(status=204)
  </code></pre>
  
  <p>Should the API do these checks or should it assume the file has already been validated?</p>
  
  <p>In Django these checks would be handled by the form, should I use a serializer to do these checks? </p>
  
  <p>If a serializer is the way to go then does it matter that there is one file as an input and various data points as an output?</p>