Skip to content

Read File

Read binary content of a file and returns a Buffer. Useful for reading text, images, or other binary files.

Interface Description

Interface Type

readSandboxFile

Parameters

ParameterTypeRequiredDescription
deviceIdstringDevice ID
filestringAbsolute file path (filePath)

Return Value

Returns Buffer (binary data).

Basic Usage

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

// Read file (returns 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)

Cooperation: try.catch@foxmail.com