title: DjangoRestFramework upload file 'CSRF Verification Failed'
body: <p>I am using DjangoRestFramework to make an API. Currently I have OAuth2 authentication working which means I can generate a valid access token to use the API.</p>
  
  <p>How do I upload a user file? I need to upload a file and relate it to the user who uploaded it.</p>
  
  <p>I am currently trying to do it this way</p>
  
  <p>api/views.py:</p>
  
  <pre><code>class FileUploadView(APIView):
      parser_classes = (FileUploadParser,)
  
      def put(self, request, filename, format=None):
          file_obj = request.FILES['file']
          # do stuff
          return Response(status=204)
  </code></pre>
  
  <p>api/urls.py contains this line:</p>
  
  <pre><code>url(r'^files/', 'api.views.FileUploadView'),
  </code></pre>
  
  <p>but when I try to upload a file I get an error stating that:</p>
  
  <pre><code>'CSRF verification failed. Request aborted'
  'Reason given for failure: CSRF cookie not set'
  </code></pre>
  
  <p>when I try this curl command:</p>
  
  <pre><code>curl -XPUT http://localhost:8000/files/ -H 'Authorization: Bearer some_access_token' -F filedata=@localfile.txt
  </code></pre>
  
  <p>Here are my REST_FRAMEWORK defaults:</p>
  
  <pre><code>REST_FRAMEWORK = {
      'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAdminUser',),
      'DEFAULT_AUTHENTICATION_CLASSES': (
          'rest_framework.authentication.OAuth2Authentication',
      )
  }
  </code></pre>