code: def convert_upload_string_to_file(i):
      
  
      import base64
  
      x=i['file_content_base64']
  
      fc=base64.urlsafe_b64decode(str(x)) # convert from unicode to str since base64 works on strings
                                          # should be safe in Python 2.x and 3.x
  
      fn=i.get('filename','')
  
      if fn=='':
         rx=gen_tmp_file({'prefix':'tmp-'})
         if rx['return']>0: return rx
         px=rx['file_name']
      else:
         px=fn
  
      fn1, fne = os.path.splitext(px)
  
      if os.path.isfile(px):
         return {'return':1, 'error':'file already exists in the current directory'}
      try:
         fx=open(px, 'wb')
         fx.write(fc)
         fx.close()
      except Exception as e:
         return {'return':1, 'error':'problem writing file='+px+' ('+format(e)+')'}
  
      return {'return':0, 'filename':px, 'filename_ext': fne}
docs: Input:  {
                file_content_base64 - string transmitted through Internet
                (filename)          - file name to write (if empty, generate tmp file)
              }
  
      Output: {
                return              - return code =  0, if successful
                                                  >  0, if error
                (error)             - error text if return > 0
                filename            - filename with full path
                filename_ext        - filename extension
              }