So I wanted to write a custom file upload parser as specified in docs 
<http://www.django-rest-framework.org/api-guide/parsers/#custom-parsers>. 

According to doc I implemented the "*parse*" method as 

----------------------------488071469102781097692083 Content-Disposition: 
form-data; name="file"; filename="email_test.msg" Content-Type: application/
vnd.ms-outlook < actual content here > ----------------------------
488071469102781097692083--

class MailParser(BaseParser):
    """
        parses email serialized data
    """


    media_type = "multipart/form-data"


    def parse(self, stream, media_type = None, parser_context = None):
        """ Here I was trying to read stream """


but when I tried to read stream it additionally had following content

    ----------------------------488071469102781097692083
    Content-Disposition: form-data; name="file"; filename="email_test.msg"
    Content-Type: application/vnd.ms-outlook  

   < actual content here >

    ----------------------------488071469102781097692083--


But when I directly read the file from request using 

request.FILES['file'] .read()

The same content wasn't there.

I wanted to understand this behaviour.

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to