@login_required
@require_POST
@xframe_options_sameorigin
def upload_async(request, media_type='image'):
 try:
  if (media_type == 'image'):
   file_info = upload_image(request)
  else:
   msg = _(u'Unrecognized media type.')
   return HttpResponseBadRequest(json.dumps({'status': 'error', 'message': msg}))
 except FileTooLargeError as e:
  return HttpResponseBadRequest(json.dumps({'status': 'error', 'message': e.args[0]}))
 if (isinstance(file_info, dict) and ('thumbnail_url' in file_info)):
  schedule_rebuild_kb()
  return HttpResponse(json.dumps({'status': 'success', 'file': file_info}))
 message = _(u'Could not upload your image.')
 return HttpResponseBadRequest(json.dumps({'status': 'error', 'message': unicode(message), 'errors': file_info}))

@ login_required @ require_POST @ xframe_options_sameorigin def upload_async ( request , media_type = 'image' ) : try : if ( media_type == 'image' ) : file_info = upload_image ( request ) else : msg = _ ( u'Unrecognized media type.' ) return HttpResponseBadRequest ( json . dumps ( { 'status' : 'error' , 'message' : msg } ) ) except FileTooLargeError as e : return HttpResponseBadRequest ( json . dumps ( { 'status' : 'error' , 'message' : e . args [ 0 ] } ) ) if ( isinstance ( file_info , dict ) and ( 'thumbnail_url' in file_info ) ) : schedule_rebuild_kb ( ) return HttpResponse ( json . dumps ( { 'status' : 'success' , 'file' : file_info } ) ) message = _ ( u'Could not upload your image.' ) return HttpResponseBadRequest ( json . dumps ( { 'status' : 'error' , 'message' : unicode ( message ) , 'errors' : file_info } ) )
upload images or videos from request .