def img_transfer():
    base = Base(API_TOKEN, SERVER_URL)
    base.auth()
    "\n    数据结构例子：其中'img', '图片链接是用户自定义的列名'\n    [{\n        '_id': 'RNn2isDfRnSPWq5HIwRT0w',\n        '_mtime': '2020-11-10T03:02:55.549+00:00',\n        'Name': '冉继伟0',\n        'img': [{\n            'name': 'cut.png',\n            'size': 2778797,\n            'type': 'file',\n            'url': 'https://dev.seafile.com/dtable-web/workspace/104/asset/1d50c674-ca45-4acf-85b8-19d6e10ca5f0/files/2020-11/cut.png'\n        }],\n        '图片链接': 'https://timgsa.baidu.com/timg?image&quality=80xxx.jpg'\n    }, {\n        '_id': 'b2lrBxnDSGm1LsZDQTVGhw',\n        '_mtime': '2020-11-04T08:47:51.562+00:00',\n        'Name': '冉继伟1'\n    }, {\n        '_id': 'RBUZ_g6qS_KER0EjaSclFA',\n        '_mtime': '2020-11-04T09:26:45.961+00:00',\n        'Name': '冉继伟2',\n        'img': None\n    }, ......]\n    "
    rows = base.list_rows(TABLE_NAME)
    count = 0
    for row in rows:
        time_stamp = get_time_stamp()
        img_url = row.get(IMG_URL_COL, None)
        img = row.get(IMG_COL, None)
        try:
            if ((not img_url) or img):
                continue
            img_name_extend = img_url.strip().split('.')[(- 1)]
            img_name_extend = (((img_name_extend in IMAGE_FILE_TYPE) and img_name_extend) or 'jpg')
            img_name = ('/tmp/image-%s.%s' % (time_stamp, img_name_extend))
            response = requests.get(img_url)
            if (response.status_code != 200):
                raise Exception('download file error')
            with open(img_name, 'wb') as f:
                f.write(response.content)
            info_dict = base.upload_local_file(img_name, name=None, relative_path=None, file_type='image', replace=True)
            row[IMG_COL] = [info_dict.get('url')]
            base.update_row('Table1', row['_id'], row)
            os.remove(img_name)
        except Exception as err_msg:
            print(('count%s-%s-%s-message: %s' % (count, row['_id'], img_url, err_msg)))
            continue
        count += 1
def img_transfer():
    base = Base(API_TOKEN, SERVER_URL)
    base.auth()
    "\n    数据结构例子：其中'img', '图片链接是用户自定义的列名'\n    [{\n        '_id': 'RNn2isDfRnSPWq5HIwRT0w',\n        '_mtime': '2020-11-10T03:02:55.549+00:00',\n        'Name': '冉继伟0',\n        'img': [{\n            'name': 'cut.png',\n            'size': 2778797,\n            'type': 'file',\n            'url': 'https://dev.seafile.com/dtable-web/workspace/104/asset/1d50c674-ca45-4acf-85b8-19d6e10ca5f0/files/2020-11/cut.png'\n        }],\n        '图片链接': 'https://timgsa.baidu.com/timg?image&quality=80xxx.jpg'\n    }, {\n        '_id': 'b2lrBxnDSGm1LsZDQTVGhw',\n        '_mtime': '2020-11-04T08:47:51.562+00:00',\n        'Name': '冉继伟1'\n    }, {\n        '_id': 'RBUZ_g6qS_KER0EjaSclFA',\n        '_mtime': '2020-11-04T09:26:45.961+00:00',\n        'Name': '冉继伟2',\n        'img': None\n    }, ......]\n    "
    rows = base.list_rows(TABLE_NAME)
    count = 0
    for row in rows:
        time_stamp = get_time_stamp()
        img_url = row.get(IMG_URL_COL, None)
        img = row.get(IMG_COL, None)
        try:
            if ((not img_url) or img):
                continue
            img_name_extend = img_url.strip().split('.')[(- 1)]
            img_name_extend = (((img_name_extend in IMAGE_FILE_TYPE) and img_name_extend) or 'jpg')
            img_name = ('/tmp/image-%s.%s' % (time_stamp, img_name_extend))
            response = requests.get(img_url)
            if (response.status_code != 200):
                raise Exception('download file error')
            with open(img_name, 'wb') as f:
                f.write(response.content)
            info_dict = base.upload_local_file(img_name, name=None, relative_path=None, file_type='image', replace=True)
            row[IMG_COL] = [info_dict.get('url')]
            base.update_row('Table1', row['_id'], row)
            os.remove(img_name)
        except Exception as err_msg:
            print(('count%s-%s-%s-message: %s' % (count, row['_id'], img_url, err_msg)))
            continue
        count += 1