def submit_file(file):
    try:
        params = {'import_event_id': file.import_event_id, 'digest': md5sum(file.file_path)}
        headers = {}
        if file.apikey:
            headers['apikey'] = file.apikey
        with open(file.file_path, 'rb') as infile:
            req = requests.put((file.base_url + '/v1/import/file'), headers=headers, params=params, data=infile)
        if (req.status_code == 200):
            print(file.file_id)
            if file.delete_after_transfer:
                os.remove(file.file_path)
            return
        else:
            raise SubmitFailedError((req.status_code, req.content))
    except SubmitFailedError as e:
        raise SubmitFailedError(('Failed to submit the file; error details follow', file, e))
    except IOError as e:
        raise SubmitFailedError(('Failed to open the file; error details follow', file, e))
def submit_file(file):
    try:
        params = {'import_event_id': file.import_event_id, 'digest': md5sum(file.file_path)}
        headers = {}
        if file.apikey:
            headers['apikey'] = file.apikey
        with open(file.file_path, 'rb') as infile:
            req = requests.put((file.base_url + '/v1/import/file'), headers=headers, params=params, data=infile)
        if (req.status_code == 200):
            print(file.file_id)
            if file.delete_after_transfer:
                os.remove(file.file_path)
            return
        else:
            raise SubmitFailedError((req.status_code, req.content))
    except SubmitFailedError as e:
        raise SubmitFailedError(('Failed to submit the file; error details follow', file, e))
    except IOError as e:
        raise SubmitFailedError(('Failed to open the file; error details follow', file, e))