python - empty request.FILES in django when upload image from android -


"itemprop =" text ">

I want to upload an image from the Android app for djnago. My Android code for uploading this image is:

  throws public Zune upload (string filepath) IOException {HttpClient httpclient = new DefaultHttpClient (); HttpPost httppost = New HttpPost (SoberRequest.UPLOAD_IMAGE_URL); File file = new file (file path); MultipartEntityBuilder Builder = MultipartEntityBuilder.create (); Builder.setMode (HttpMultipartMode.BROWSER_COMPATIBLE); File body cbFile = new file body (file, "image / JPEG"); Builder.addPart ("image", cbFile); HttpEntity mpEntity = builder.build (); Httppost.setEntity (mpEntity); Httppost.setHeader ("encrypt", "multipart / form-data"); HttpResponse response = httpclient.execute (httppost); HttpEntity unit = response.getEntity (); ...}  

And to get this and save image, my Django code is:

  @csrf_exempt def get_image (request): try : If requested. Method == "post": destination_path = open ("images / filan.jpg", "west bengal +") print (request.FILES) image = request.FILES ['image'] destination_path.write (image) destination_path.close Return to HttpResponse (json.dumps (json_data), mime type = ("json_data"), "json_data" {json_data}, mso type = json_data = {"status": successful} return HttpResponse (json.dumps (json_data), mime type = json_mimeType) Json_mimeType)  

When I print the request. FILES, it's empty :. And the DJine enhances this multivitale Dicticier arpision. What's the problem? Thanks


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -