def write_with_new_filename(self, tmp_dir, data, file_extension, dict_to_fill, as_byte=False):
    try:
        random_suffix = ('_' + ''.join((random.SystemRandom().choice(string.ascii_lowercase) for _ in range(16))))
        new_file_name = 'ph_long_file_name_{0}{1}'.format(random_suffix, file_extension)
        file_path = os.path.join(tmp_dir, new_file_name)
        with open(file_path, 'wb') as f:
            if as_byte:
                f.write(data.as_bytes())
            else:
                f.write(data)
        dict_to_fill.append({'file_name': new_file_name, 'file_path': file_path})
    except Exception as e:
        self._base_connector.debug_print('Exception while writing file: {}'.format(e))
def write_with_new_filename(self, tmp_dir, data, file_extension, dict_to_fill, as_byte=False):
    try:
        random_suffix = ('_' + .join((random.SystemRandom().choice(string.ascii_lowercase) for _ in range(16))))
        new_file_name = 'ph_long_file_name_{0}{1}'.format(random_suffix, file_extension)
        file_path = os.path.join(tmp_dir, new_file_name)
        with open(file_path, 'wb') as f:
            if as_byte:
                f.write(data.as_bytes())
            else:
                f.write(data)
        dict_to_fill.append({'file_name': new_file_name, 'file_path': file_path})
    except Exception as e:
        self._base_connector.debug_print('Exception while writing file: {}'.format(e))