does Storage support reading/writing binary data?

Posted on
  • Hello again!

    Does the Storage module support reading/writing binary data?

    • StorageFile does not (as it uses 0xFF for internal purposes)
    • I do not want to use atob/btoa as these do not really support "chunking" (i.e., chunks read must always be of the same size as chunks written)
    • if possible, I would like to read/write ArrayBuffers - is that possible?

    (an alternative question could be: are strings in Bangle.js Unicode strings? or ASCII ones? if the latter, strings could be used instead of ArrayBuffers, making "binary" I/O just identical to "text" I/O)

    Thanks in advance for your help!

  • Yes, if you have a standard storage file you can write binary data to it.

    Easiest thing to do is give it a go, but I'm pretty sure you can just do require("Storage").write("MyFile", new Uint8Array([....]))

    When you read, I think you'll still get a String, but it's easy to convert with E.toArrayBuffer:­ArrayBuffer

  • Ok, I will try it, thanks!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

does Storage support reading/writing binary data?

Posted by Avatar for Andreas_Rozek @Andreas_Rozek