file
TIP
文件读写操作
compressZipFile (code, srcFilename, destFilename)
压缩ZIP文件
返回无参数 类型 作用 备注 code string 本地目录数据端点编码 srcFilename string 压缩前文件名 destFilename string 压缩后文件名 例 :
await api.file.compressZipFile('123abc','1.xlsx','2.zip')
copyLocalFile (srcLocalFileCode, srcFilename, destLocalFileCode, destFilename)
复制本地文件目录文件
| 参数 | 类型 | 作用 | 备注 |
|---|---|---|---|
| srcLocalFileCode | string | 源本地目录数据端点编码 | |
| srcFilename | string | 复源文件名 | |
| destLocalFileCode | string | 目标本地目录数据端点编码 | |
| destFilename | string | 目标文件名 |
例 :
await api.file.copyLocalFile('123abc','1.xlsx','456def','2.xlsx')
deleteLocalFile (code, filename)
删除本地文件目录文件
| 参数 | 类型 | 作用 | 备注 |
|---|---|---|---|
| code | string | 本地目录数据端点编码 | |
| filename | string | 文件名 |
例 :
await api.file.deleteLocalFile('123abc','1.xlsx')
getLocalFileStream(code,filename)
获取本地文件输入流
| 参数 | 类型 | 作用 | 备注 |
|---|---|---|---|
| code | string | 本地目录数据端点编码 | |
| filename | string | 文件名 |
例 :
await api.file.getLocalFileStream('123abc','1.xlsx')
moveLocalFile (srcLocalFileCode, srcFilename, destLocalFileCode, destFilename)
移动本地文件目录文件
| 参数 | 类型 | 作用 | 备注 |
|---|---|---|---|
| srcLocalFileCode | string | 移动前本地目录数据端点编码 | |
| srcFilename | string | 移动前文件名 | |
| destLocalFileCode | string | 移动后本地目录数据端点编码 | |
| destFilename | string | 移动后文件名 |
例 :
await api.file.moveLocalFile('123abc','1.xlsx','456def','2.xlsx')
readLocalFileBase64 (code, filename)
从本地文件目录获取文件内容(base64)
| 参数 | 类型 | 作用 | 备注 |
|---|---|---|---|
| code | string | 本地目录数据端点编码 | |
| filename | string | 文件名 |
例 :
await api.file.readLocalFileBase64('123abc','1.xlsx')
readLocalFileString (code, filename)
从本地文件目录读取文件内容
| 参数 | 类型 | 作用 | 备注 |
|---|---|---|---|
| code | string | 本地目录数据端点编码 | |
| filename | string | 文件名 |
例 :
await api.file.readLocalFileString('123abc','1.xlsx')
uncompressZip (code, filename)
解压ZIP文件
返回无
| 参数 | 类型 | 作用 | 备注 |
|---|---|---|---|
| code | string | 本地目录数据端点编码 | |
| filename | string | 文件名 |
例 :
await api.file.uncompressZip('123abc','1.zip')
uploadFTP(localDirCode, ftpServerCode)
上传到FTP服务器
返回无
| 参数 | 类型 | 作用 | 备注 |
|---|---|---|---|
| localDirCode | string | 本地目录数据端点编码 | |
| ftpServerCode | string | FTP服务数据端点编码 |
例 :
await api.file.uploadFTP('123abc','456def')
uploadSFTP(localDirCode, sftpServerCode)
上传到SFTP服务器
返回无参数 类型 作用 备注 localDirCode string 本地目录数据端点编码 sftpServerCode string SFTP服务数据端点编码 例 :
await api.file.uploadSFTP('123abc','456def')
writeLocalFileCSV (code, header, data, separatorCode, showTitle, filename)
写入CSV文件内容到本地文件目录
| 参数 | 类型 | 作用 | 备注 |
|---|---|---|---|
| code | string | 本地目录数据端点编码 | |
| header | array | 写入的CSV文件表头名称 | code为对应字段,name为EXCEL表头名称 |
| data | array | 写入的CSV文件数据 | |
| separatorCode | string | 分隔符 | comma 逗号、colon 冒号、double_colon 双冒号、tab 制表符 |
| showTitle | string | 是否显示标题 | false、true |
| filename | string | 写入的CSV文件名称 |
例 :
const header =
[
{ code: 'usercode', name: '用户编码' },
{ code: 'username', name: '用户名称' }
]
const data =
[
{ usercode: 'zhangsan', username: '张三' },
{ usercode: 'lisi', username: '李四' }
]
await api.file.writeLocalFileCSV('123abc',header, data, 'tab','true', '1.csv')
writeLocalFileExcel (code, header, data, sheetName, filename)
写入EXCEL文件内容到本地文件目录
返回无
| 参数 | 类型 | 作用 | 备注 |
|---|---|---|---|
| code | string | 本地目录数据端点编码 | |
| header | array | 字段编码、名称对应数组 | code为对应字段,name为EXCEL表头名称 |
| data | array | 数据 | |
| sheetName | string | sheet名称 | |
| filename | string | excel文件名 |
例 :
const header =
[
{ code: 'usercode', name: '用户编码' },
{ code: 'username', name: '用户名称' }
]
const data =
[
{ usercode: 'zhangsan', username: '张三' },
{ usercode: 'lisi', username: '李四' }
]
await api.file.writeLocalFileExcel('123abc',header, data, '用户信息', '1.xlsx')
writeLocalFileString (code, filename, text)
写入文件内容到本地文件目录
返回无参数 类型 作用 备注 code string 本地目录数据端点编码 filename string 文件名 text array 写入内容 例 :
const content =
[
{ usercode: 'zhangsan', username: '张三' },
{ usercode: 'lisi', username: '李四' }
]
await api.file.writeLocalFileString('123abc','1.xlsx', content)