跳到主要内容

单元格添加附件

向单元格添加附件, 图片文件最大不能超过20M。

请求

curl -vvv "$API_HOST/open/api/v1/tablenodes/$table_id/rows/$row_id/cells/$column_id/attachments/" -H "Content-Type: application/json" -H "Authorization: $access-token"  -d '$request_body'

请求体form-data 示例

{
"file": "attachment.csv"
}

参数说明

NameTypeDescriptionRequired
filefileattachment fileY

Python 示例

def add_attachment(access_token, table_id, row_id, column_id, attachment_file_path):
url = '%s/open/api/v1/tablenodes/%d/rows/%s/cells/%s/attachments/' %( API_HOST, table_id, row_id,column_id)
files = {'file': open(attachment_file_path, 'rb')}
headers = {'Authorization': access_token}
req = requests.post(url, headers=headers, files=files)
return req.json()

响应

NameTypeDescription
detailobjectattachment info
∟ attachmentobjectattachment info
∟ attachmentsarrayattachment array
∟ columnIDstringcolumn id
∟ projectIDint64project id
∟ rowIDstringrow id
∟ tableNodeIDint64table id

响应示例

{
"code": 0,
"detail": {
"attachment": {
"createTime": "2023-05-13T18:59:44.417622+08:00",
"fileExt": ".json",
"fileID": "clatxt69zta8",
"fileName": "test.json",
"fileSize": 161498,
"fileType": "application/json",
"uploaderID": 1,
"url": "https://hk-maptable-public.oss-cn-hongkong.aliyuncs.com/devfiles/clatxt69zta8"
},
"attachments": null,
"columnID": "645f6d304444eb50dc9d63c6",
"projectID": 2,
"rowID": "6457589faf1c21691b34dab3",
"tableNodeID": 40
},
"extra": null,
"message": "OK",
"requestID": null
}