def download_file(session, file_id, file_name, request_headers, error):
    'Download BaseSpace file.'
    response = make_get_request(session=session, url=get_api_file_content_url(file_id=file_id), headers=request_headers, error=error, stream=True)
    try:
        with open(file_name, 'wb') as f:
            chunk_size = ((1024 * 1024) * 10)
            for chunk in response.iter_content(chunk_size=chunk_size):
                f.write(chunk)
    except FileNotFoundError:
        error(f'Could not save file to {file_name}, due to directory not being found')
    except PermissionError:
        error(f'Could not save file to {file_name}, due to insufficient permissions')
    except RequestException:
        error(f'Could not save file to {file_name}, due to a network error')
Download BaseSpace file.
def download_file(session, file_id, file_name, request_headers, error):
    
    response = make_get_request(session=session, url=get_api_file_content_url(file_id=file_id), headers=request_headers, error=error, stream=True)
    try:
        with open(file_name, 'wb') as f:
            chunk_size = ((1024 * 1024) * 10)
            for chunk in response.iter_content(chunk_size=chunk_size):
                f.write(chunk)
    except FileNotFoundError:
        error(f'Could not save file to {file_name}, due to directory not being found')
    except PermissionError:
        error(f'Could not save file to {file_name}, due to insufficient permissions')
    except RequestException:
        error(f'Could not save file to {file_name}, due to a network error')