diff --git a/common/modules/mixly-modules/web/ampy.js b/common/modules/mixly-modules/web/ampy.js index db348eac..42de7be1 100644 --- a/common/modules/mixly-modules/web/ampy.js +++ b/common/modules/mixly-modules/web/ampy.js @@ -237,8 +237,10 @@ class AmpyExt extends Ampy { } await this.exec(`file = open('${filename}', 'wb')`, timeout); let buffer = null; - if (typeof data === 'string') { + if (data.constructor === String) { buffer = this.#device_.encode(data); + } else if (data.constructor === ArrayBuffer) { + buffer = new Uint8Array(data); } else { buffer = data; } @@ -255,7 +257,7 @@ class AmpyExt extends Ampy { } await this.exec(`file.write(b'${writeStr}')`, timeout); } - await this.exec(`file.close()`, timeout); + await this.exec('file.close()', timeout); } async ls(directory = '/', longFormat = true, recursive = false, timeout = 5000) {