Skip to main content
Version: v1.0

hmFS.write(fileId, buffer, position, length)

For an introduction to the Zepp OS Mini Program file system, please refer to File System.

Write buffer to the file.

Type

(fileId: number, buffer: ArrayBuffer, position: number, length: number) => result

Parameters

ParametersDescriptionRequiredTypeDefault
fileIdfile handleyesnumber-
bufferThe buffer that will be filled with the read file datayesArrayBuffer-
positionOffset based on buffer first addressyesnumber-
lengththe number of bytes to writeyesnumber-

result

ParametersDescriptionType
resultThe result of the operation, 0 means successnumber

Please refer to File System - Error Code for the rest of the error codes.

Code example

Page({
build() {
const test_buf = new Uint8Array(10)
const test_buf2 = new Uint8Array(test_buf.length)

const file = hmFS.open('test_file.txt', hmFS.O_RDWR | hmFS.O_CREAT)
hmFS.write(file, test_buf.buffer, 0, test_buf.length)
}
})