An exception occurred while processing a WSGI script - IOError: Failed to write data

I am trying to save a server side image. I get it as a base64 string, so I decode it first and then save it to the database. However, this failed, so I checked the server error log and I found the following error.log

[Tue May 21 14:26:38 2013] [error] [client 41.236.182.133] mod_wsgi (pid=4952): Exception occurred processing WSGI script '/root/AR_BROWSER/example/wsgi.py'. [Tue May 21 14:26:38 2013] [error] [client 41.236.182.133] IOError: failed to write data 

I checked wsgi.py

 import os import sys path = '/root/AR_BROWSER/example' sys.path.append('/root/AR_BROWSER/example') sys.path.append('/root/AR_BROWSER') sys.path.append('/root/AR_BROWSER/example/app') os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() 

But I can’t find something wrong. Any idea what could be causing this problem ?! code responsible for saving the image

  @csrf_exempt def create_app(request): appName = request.POST['name'] user = request.POST['userID'] c = request.POST['category'] i = request.POST['image'] imgdata = base64.b64decode(i) t = datetime.now() filename = t.strftime('test.jpg') with open(filename, 'w') as f: f.write(imgdata) f.close() u=App_User.objects.get(id=user) apps = App.objects.create(name = appName, category=c, user_id = u.id, app_logo=File(filename)) apps.save() return HttpResponse("You created %s." % apps.name) 
+6
source share
1 answer

This message from mod_wsgi without tracing usually means that the HTTP client closed the connection before all response data can be written back to mod_wsgi.

+7
source

Source: https://habr.com/ru/post/945495/


All Articles