title: How to return binary array in django-rest framewrok?
body: <p>I am working on the server-client web service.</p>
  
  <p>I want the server to download the file from a url and return the raw byte of the content of the file.</p>
  
  <p>However, it seems that the received bytes from ajax is corrputed. </p>
  
  <p>Here is the server side:</p>
  
  <pre><code>from rest_framework.response import Response
  import urllib2
  class MyView(APIView):
      def post(self, request):
          url = request.DATA['url']
          conn = urllib2.urlopen(url)
          byte = conn.read()
          conn.close()
          return Response({'blob':byte})
  </code></pre>
  
  <p>Here is the client side,</p>
  
  <pre><code>$.ajax({
      url: 'myurl',
      type: 'POST',
      contentType: "application/json; charset=utf-8",
      data: JSON.stringify({
          "url": url,
      }),                        
      success: function(response, textStatus, jqXhr) {
      if (response) {
          try {
              var blob=response.blob;
              // process blob, but it is corrupted
           } catch (e) {
              displayError(e);
       }
  
       },
       error: function(jqXHR, textStatus, errorThrown) {
           var err = parseError(jqXHR, textStatus, errorThrown);
           displayError(err);
       }
  });
  </code></pre>
  
  <p>What is the proper way to do this with django-rest framework?</p>
  
  <p>Thank you!</p>