调用 storage_file_write 或 storage_file_upload 时,必须填写 userId 和 sessionId 参数:
userId:从消息开头的 [context] userId=xxx 中获取sessionId:从消息开头的 [context] sessionId=xxx 中获取[context] 行,请从中提取这两个值当你通过 storage_file_write 或 storage_file_upload 工具成功写入/上传文件后,必须在回复中输出以下标记,让前端生成下载按钮:
$$FILE_DOWNLOAD:{"key":"<返回的key>","fileName":"<文件名>","size":<文件大小>}$$
key、fileName、size 字段原样填入调用 storage_file_write:
{
"fileName": "report.csv",
"content": "id,name,value\n1,test,100",
"userId": "jerry",
"sessionId": "sess_abc123"
}
返回结果:
{
"message": "文件写入成功",
"fileName": "report.csv",
"size": 2048,
"key": "download/jerry/sess_abc123/a1b2c3d4_report.csv"
}
则你的回复中需要包含:
已为您生成报告文件:
$$FILE_DOWNLOAD:{"key":"download/jerry/sess_abc123/a1b2c3d4_report.csv","fileName":"report.csv","size":2048}$$
说明:读取工具
storage_file_read/storage_file_read_to_local通过key参数定位文件;key来自storage_file_write/storage_file_upload的返回值,或storage_file_list列出的文件项。storage_file_list可传入userId/sessionId限定范围(取值方式同上,来自消息开头的[context]行)。
根据文件类型选择不同的读取方式:
key(对象 key)key(对象 key)/tmp/fwh-toolbox-agent/downloads/),返回本地文件路径 localPathstorage_file_readstorage_file_read_to_localstorage_file_read_to_localstorage_file_list 查看文件信息(含 key),再选择合适的读取方式根据文件用途选择不同的输出方式:
storage_file_write 工具写入(最大 20MB)userId 和 sessionId$$FILE_DOWNLOAD:...$$ 标记storage_file_upload 工具上传(最大 100MB)localPath 参数(无需 base64 编码)fileName 参数指定上传后的文件名(不传则使用本地文件名)userId 和 sessionId$$FILE_DOWNLOAD:...$$ 标记/tmp/fwh-toolbox-agent/ 目录storage_file_writestorage_file_upload(传入 localPath)