title: Django/Tastypie Image upload - Invalid boundary in multipart: None?
body: <p>I am new to python/django/tastypie and am trying to do a file upload. I am getting a very strange (to me it is) error that I can not seem to figure out. Whenever I try to upload a photo via my rest client (CocoaRest Client), it bombs with the following error:</p>
  
  <pre><code>{
    "error_message" : "Invalid boundary in multipart: None",
    "traceback" : "Traceback (most recent call last):\n\n  File \"/Users/crown/Documents/Sources/Virtualenvs/GOCApi/lib/python2.7/site-packages/tastypie/resources.py\", line 195, in wrapper\n    response = callback(request, *args, **kwargs)\n\n  File \"/Users/crown/Documents/Sources/GOCApi/api/resources/member.py\", line 85, in post_profile_picture\n    if('image' in request.FILES):\n\n  File \"/Users/crown/Documents/Sources/Virtualenvs/GOCApi/lib/python2.7/site-packages/django/core/handlers/wsgi.py\", line 214, in _get_files\n    self._load_post_and_files()\n\n  File \"/Users/crown/Documents/Sources/Virtualenvs/GOCApi/lib/python2.7/site-packages/django/http/request.py\", line 217, in _load_post_and_files\n    self._post, self._files = self.parse_file_upload(self.META, data)\n\n  File \"/Users/crown/Documents/Sources/Virtualenvs/GOCApi/lib/python2.7/site-packages/django/http/request.py\", line 176, in parse_file_upload\n    parser = MultiPartParser(META, post_data, self.upload_handlers, self.encoding)\n\n  File \"/Users/crown/Documents/Sources/Virtualenvs/GOCApi/lib/python2.7/site-packages/django/http/multipartparser.py\", line 69, in __init__\n    raise MultiPartParserError('Invalid boundary in multipart: %s' % boundary)\n\nMultiPartParserError: Invalid boundary in multipart: None\n"
  }
  </code></pre>
  
  <p>I have the header set "Content-Type: multipart/form-data" as well as have a file added to the files tab.</p>
  
  <p>Here is my method that I am calling from the client:</p>
  
  <pre><code>def post_profile_picture(self, request, *args, **kwargs):
          if(request.method == 'POST'):
              if(str(request.META['CONTENT_TYPE']) != "multipart/form-data"):
                  return self.create_response(request, HelperMethods.api_return_msg("Unsupported media type"), response_class=http.HttpBadRequest)
              else:
                  if('image' in request.FILES):
  
                      #bunch of code removed
  
                      return self.create_response(request, {"profile_img" : profile_img_key_name, "thumb_img" : thumb_img_key_name}, response_class=http.HttpResponse)
                  else:
                      return self.create_response(request, HelperMethods.api_return_msg("No image found"), response_class=http.HttpBadRequest)
          else:
              return self.create_response(request, HelperMethods.api_return_msg("Method not allowed"), response_class=http.HttpMethodNotAllowed)
  </code></pre>
  
  <p>When I do a print(request) before if('image' in request.FILES), I do not get that same error, it actually jumps to my else and prints "No image found", which is strange that it wouldn't blow up the same way.</p>
  
  <p>I'm not sure what else I need to do, add more headers? set a "boundary" (not sure what that is)... any help is much appreciated. I am willing to try things out and post results on here for better assistance. Thanks!</p>