{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/41660295","id":41660295,"diff_hunk":"@@ -1,7 +1,90 @@\n-from rest_framework import parsers\n+\"\"\"\n+Custom DRF request parsers.  These can be used by views to handle different\n+content types, as specified by `<Parser>.media_type`.\n \n+To use these in an APIView, set `<View>.parser_classes` to a list including the\n+desired parsers.  See http://www.django-rest-framework.org/api-guide/parsers/\n+for details.\n+\"\"\"\n \n-class MergePatchParser(parsers.JSONParser):\n+from django.utils.translation import ugettext as _\n+\n+from rest_framework.exceptions import ParseError, UnsupportedMediaType\n+from rest_framework.parsers import FileUploadParser, JSONParser\n+\n+\n+class TypedFileUploadParser(FileUploadParser):\n+    \"\"\"\n+    Handles upload of files, ensuring that the media type is supported, and\n+    that the uploaded filename matches the Content-type.\n+\n+    Requirements:\n+        * The view must have an `upload_media_types` attribute which is a\n+          set (or other container) enumerating the mimetypes of the supported\n+          media formats\n+\n+          Example:\n+\n+              View.upload_media_types = {'audio/mp3', 'audio/ogg', 'audio/wav'}\n+\n+        * Content-type must be set to a supported type (as\n+          defined in View.upload_media_types above).\n+\n+          Example:\n+\n+              Content-type: audio/ogg\n+\n+        * Content-disposition must include a filename with a valid extension\n+          for the specified Content-type.\n+\n+          Example:\n+\n+              Content-disposition: attachment; filename=\"lecture-1.ogg\"\n+    \"\"\"\n+\n+    media_type = '*/*'\n+\n+    # Add more entries to this as needed.  All extensions should be lowercase.\n+    file_extensions = {","path":"openedx/core/lib/api/parsers.py","position":50,"original_position":50,"commit_id":"a6735677997824f77f9e4fe72e6f097e57c2cf7b","original_commit_id":"a6735677997824f77f9e4fe72e6f097e57c2cf7b","user":{"login":"dan-f","id":2146312,"avatar_url":"https://avatars.githubusercontent.com/u/2146312?v=3","gravatar_id":"","url":"https://api.github.com/users/dan-f","html_url":"https://github.com/dan-f","followers_url":"https://api.github.com/users/dan-f/followers","following_url":"https://api.github.com/users/dan-f/following{/other_user}","gists_url":"https://api.github.com/users/dan-f/gists{/gist_id}","starred_url":"https://api.github.com/users/dan-f/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dan-f/subscriptions","organizations_url":"https://api.github.com/users/dan-f/orgs","repos_url":"https://api.github.com/users/dan-f/repos","events_url":"https://api.github.com/users/dan-f/events{/privacy}","received_events_url":"https://api.github.com/users/dan-f/received_events","type":"User","site_admin":false},"body":"`self.file_extensions` seems redundant, given that the view already declares an `upload_media_types` attribute. It's more intuitive to me for the view's `upload_media_types` to be the source of truth when it comes to media types we'll parse.","created_at":"2015-10-09T18:06:58Z","updated_at":"2015-10-09T18:06:58Z","html_url":"https://github.com/edx/edx-platform/pull/10046#discussion_r41660295","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/10046","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/41660295"},"html":{"href":"https://github.com/edx/edx-platform/pull/10046#discussion_r41660295"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10046"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/10046","id":46832403,"html_url":"https://github.com/edx/edx-platform/pull/10046","diff_url":"https://github.com/edx/edx-platform/pull/10046.diff","patch_url":"https://github.com/edx/edx-platform/pull/10046.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/10046","number":10046,"state":"open","locked":false,"title":"MA-1416 image mimetype uploads","user":{"login":"jcdyer","id":77486,"avatar_url":"https://avatars.githubusercontent.com/u/77486?v=3","gravatar_id":"","url":"https://api.github.com/users/jcdyer","html_url":"https://github.com/jcdyer","followers_url":"https://api.github.com/users/jcdyer/followers","following_url":"https://api.github.com/users/jcdyer/following{/other_user}","gists_url":"https://api.github.com/users/jcdyer/gists{/gist_id}","starred_url":"https://api.github.com/users/jcdyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcdyer/subscriptions","organizations_url":"https://api.github.com/users/jcdyer/orgs","repos_url":"https://api.github.com/users/jcdyer/repos","events_url":"https://api.github.com/users/jcdyer/events{/privacy}","received_events_url":"https://api.github.com/users/jcdyer/received_events","type":"User","site_admin":false},"body":"https://openedx.atlassian.net/browse/MA-1416\r\n\r\n@nasthagiri ","created_at":"2015-10-05T20:54:32Z","updated_at":"2015-10-09T18:06:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"99e42b6f64da8010449e7037c22faaa082b4f26d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/10046/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/10046/comments","review_comment_url":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-platform/issues/10046/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/a6735677997824f77f9e4fe72e6f097e57c2cf7b","head":{"label":"edx:cdyer/MA-1416-image-mimetype-uploads","ref":"cdyer/MA-1416-image-mimetype-uploads","sha":"a6735677997824f77f9e4fe72e6f097e57c2cf7b","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-10-09T16:40:23Z","pushed_at":"2015-10-09T18:06:52Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":2119502,"stargazers_count":2163,"watchers_count":2163,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1306,"mirror_url":null,"open_issues_count":122,"forks":1306,"open_issues":122,"watchers":2163,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"0d2dc431c93c2aeb34d0106dcae35e875cbce63c","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-10-09T16:40:23Z","pushed_at":"2015-10-09T18:06:52Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":2119502,"stargazers_count":2163,"watchers_count":2163,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1306,"mirror_url":null,"open_issues_count":122,"forks":1306,"open_issues":122,"watchers":2163,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10046"},"html":{"href":"https://github.com/edx/edx-platform/pull/10046"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/10046"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/10046/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10046/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10046/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/a6735677997824f77f9e4fe72e6f097e57c2cf7b"}}}}