code: def file_download(user_session, request):
      
      logger.debug('Download file: %s', vars(request))
      response = user_session.session.get(
          request.href,
          params=request.params,
          headers=request.headers,
          stream=True)
  
      if response.status_code == 200:
          logger.debug('Streaming to file... Content length: %s', len(response.content))
          try:
              path = os.path.abspath(request.filename)
              logger.debug('Operation: %s, saving to file: %s', request.href, path)
  
              with open(path, "wb") as handle:
                  for chunk in response.iter_content(chunk_size=1024):
                      if chunk:
                          handle.write(chunk)
                          handle.flush()
          except IOError as e:
              raise IOError('Error attempting to save to file: {}'.format(e))
  
          result = SMCResult(response, user_session=user_session)
          result.content = path
          return result
      else:
          raise SMCOperationFailure(response)
docs: Called when GET request specifies a filename to retrieve.
      
      :param Session user_session: session object
      :param SMCRequest request: request object
      :raises SMCOperationFailure: failure with reason
      :rtype: SMCResult