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
readSandboxFileParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
deviceId | string | ✅ | Device ID |
file | string | ✅ | Absolute 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)