def file_upload_echo_content(request):
 def read_and_close(f):
  with f:
   return f.read().decode('utf-8')
 r = {k: read_and_close(f) for (k, f) in request.FILES.items()}
 return HttpResponse(json.dumps(r))

def file_upload_echo_content ( request ) : def read_and_close ( f ) : with f : return f . read ( ) . decode ( 'utf-8' ) r = { k : read_and_close ( f ) for ( k , f ) in request . FILES . items ( ) } return HttpResponse ( json . dumps ( r ) )
simple view to echo back the content of uploaded files for tests .