文档导出导入
导入
接口
POST <SHIMO_API>/files/import
鉴权信息
参数 | 说明 |
---|---|
scope | "write" |
参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
name | String | N | 文档标题,默认无标题 |
type | String | Y | 导入文件的类型
|
fileBase64 | String | Y | 待导入文档的 base64 字符串,注意并不是 Data URL,不应包含 data:[<mediatype>][;base64], 部分 |
支持类型 (未列出的为暂不支持) :
文档类型 | 支持类型 |
---|---|
文档 | docx |
表格 | xlsx |
代码示例
const request = require('node-fetch')
fetch('<SHIMO_API>/files/import', {
method: 'POST',
headers: {
Authorization: 'Bearer <Access Token>',
'Content-Type': 'application/json'
},
body: {
type,
fileBase64: fs.readFileSync(file.path).toString('base64'),
name: file.name
}
})
.then(res => res.json())
.then(body => console.log(body.data))
返回示例
{
"head": 1,
"guid": "JyRX1679PL86rbTk",
"type": "document",
"content": "shimo content"
}
导出
接口
GET <SHIMO_API>/files/<GUID>/export
鉴权信息
参数 | 说明 |
---|---|
scope | "read" |
info.fileGuid | <GUID> |
info.filePermissions.readonly | true |
参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
name | String | N | 导出的文件名,默认为空。当导出 PDF 时,传入的 name 会作为 PDF 正文的主标题而被使用。 |
toType | String | Y | 导出类型 |
支持类型 (未列出的为暂不支持) :
文档类型 | 支持类型 |
---|---|
文档 | docx、pdf |
表格 | xlsx |
幻灯片 | pptx |
代码示例
const request = require('node-fetch')
fetch('<SHIMO_API>/files/<GUID>/export?toType=docx', {
method: 'GET',
headers: {
Authorization: 'Bearer <Access Token>',
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(body => console.log(body.data))
返回示例
- 返回的
content-type
为text/plain
file-server-domain
和exported-file-path
为动态输出,请勿以此为准做一些工作
https://file-server-domain/<exported-file-path>