往表格中添加图片或者文件包括三个步骤
注意: 文件和图片是由 dtable web 部分负责处理的,所以第一步中需要使用 dtable web 的地址,也就是 https\://cloud.seatable.cn。
也就是,不要使用 https\://dtable-server.seatable.cn 或者 https\://xxxxx/dtable-server (如果你是私有部署)
注意 2: 文件上传使用的是 API Token,不是 access token。附件上传下载是 dtable-web 组件负责的。所以用 API token。访问 dtable-server 组件才需要使用 access token。
GET /api/v2.1/dtable/app-upload-link/
Sample request
curl -H 'Authorization:Token 0303f89b3607fb86039fdffcf1be6383797b437f' -H 'Accept: application/json; indent=4' "https://cloud.seatable.cn/api/v2.1/dtable/app-upload-link/"
Sample response
{
"upload_link": "https://cloud.seatable.cn/seafhttp/upload-api/85ac7ebe-e19d-4133-91df-07b4a78ad5e7",
"parent_path": "/asset/2c971f18-8b3d-4a5d-adbf-4c1acb9625c7",
"img_relative_path": "images/2021-02",
"file_relative_path": "files/2021-02"
}
Errors
POST the "upload_link" returned by the previous step, for example, https\://cloud.seatable.cn/seafhttp/upload-api/85ac7ebe-e19d-4133-91df-07b4a78ad5e7
Request parameters
The following parameters are set in the URL:
1
. If this parameter is not set, the file ids will be returned in a tab-separated string. New apps should set ret-json to 1.Sample request without ret-json
parameter
curl -X POST 'https://cloud.seatable.cn/seafhttp/upload-api/ca2b9d01-ff61-4030-9808-82eba92f62a5' -H 'Authorization: Token 8430a9b42441b8815df35bbc01af394176b23aed' -F 'file=@/Users/ranjiwei/Desktop/rows.py 11-20-34-467.py' -F parent_dir=/asset/2c971f18-8b3d-4a5d-adbf-4c1acb9625c7 -F relative_path=files/2021-02
Sample response without ret-json
parameter
20ed0b677a6f0774cf5895c826043da9989125a1
Sample request with ret-json
parameter
curl -X POST 'https://cloud.seatable.cn/seafhttp/upload-api/ca2b9d01-ff61-4030-9808-82eba92f62a5?ret-json=1' -H 'Authorization: Token 8430a9b42441b8815df35bbc01af394176b23aed' -F 'file=@/Users/ranjiwei/Desktop/rows.py 11-20-34-467.py' -F parent_dir=/asset/2c971f18-8b3d-4a5d-adbf-4c1acb9625c7 -F relative_path=files/2021-02
Sample response with ret-json
[
{
"name": "rows.py 11-20-34-467.py",
"id": "20ed0b677a6f0774cf5895c826043da9989125a1",
"size": 4037
}
]
Errors
Please refer row.md for detail. Here is part example of request parameters of append a row
curl -H 'Authorization: Token xxxxx' .....
-d '{"row": {"Name": "I am new Row"},"table_name": "Table1"}'
If you want to update the row data of file-type columns("my file"), you can construct the data structure of "row" below as request parameters
{
"row": {
"Name": "I am new Row",
"my_file": [
{
"name": "xxx.pdf",
"size": 48683,
"type": "file",
"url": "https://cloud.seatable.cn/workspace/49132/asset/2c971f18-8b3d-4a5d-adbf-4c1acb9625c7/files/2021-02/xxx.pdf"
}
]
},
"table_name": "Table1"
}'
Similarly, you can also update a image-type-column("my image") table cell as above, the data structure is a little different which only contains image url:
https\://cloud.seatable.cn/workspace/:workspace_id/:parent_path/:img_relative_path/:img_name
{
"row": {
"Name": "I am new Row",
"my_image": [
'https://cloud.seatable.cn/workspace/49132/asset/2c971f18-8b3d-4a5d-adbf-4c1acb9625c7/images/2021-02/06.png'
]
},
"table_name": "Table1"
}'
GET /api/v2.1/dtable/app-download-link/
Request parameters
Sample request
curl -H 'Authorization:Token 0303f89b3607fb86039fdffcf1be6383797b437f' -H 'Accept: application/json; indent=4' "https://cloud.seatable.cn/api/v2.1/dtable/app-download-link/?path=/images/2020-02/test_pic.jpg"
Sample response
{
"download_link": "https://cloud.seatable.cn/seafhttp/files/498fe8b6-68f4-4878-8ce7-91517b9c6e1c/test_pic.jpg"
}
Errors
Last modified by seatable, 2023-05-18