Skip to content

读取文件内容

读取指定文件的二进制内容,返回 Buffer。可用于读取文本、图片或其他二进制文件。

接口说明

接口类型

readSandboxFile

参数

参数名类型必填说明
deviceIdstring设备 ID
filestring文件绝对路径(filePath)

返回值

返回 Buffer(二进制数据)。

基本使用

javascript
const _device = await apiInvoke('getDeviceInfo', {
    deviceId: 'P72578581E07'
})

// 读取文件(返回 Buffer)
const _raw = await apiInvoke('readSandboxFile', {
    deviceId: 'P72578581E07',
    file: `${_device.info.sandboxPath}/result.txt`
})

const _buf = Buffer.from(_raw)
const _text = _buf.toString('utf-8')
console.log(_text)

商务合作:try.catch@foxmail.com