语言

Menu
Sites
Language
Uint8Array to Array

Hi

I met a strange problem. I would like to convert Uint8Array  to Array in order to use with

Filesystem API methods FileStream.writeBytes(octet[] byteData);

The method not accept Uint8Array. After converting like that Array [n] = Uint8Array [n], it works,

but this solution is extremly slow for bigger array.

 

Regards,

slaw

响应

4 回复
AVSukhov

Hello,

Why are you using Uint8Array? 

Do you have any requirements on it? And where did you get this data (Canvas, XMLHttpRequest, WebGL)?

Slawek Kowalski

I use lib zip.js to pack/unpack files - http://gildas-lormeau.github.io/zip.js/

I need Uint8Array to get bytes from Blob by FileReader.  It seems this HTML5 objects are not

compatible with tizen API well. Now I understand why Samsung wants to use in future only HTML5

standards like File API.

 

AVSukhov

As i khown, using FileReader you can get data as ArrayBuffer, as DataURL ...

And you can use write the format to write file using device FileSystem API (writeBase64() or write() as string)

Slawek Kowalski

I decide to use readAsArrayBuffer() for binary files and readAsText() to read text files.

Base64 make output bigger about 33% and writing such data need more time (must be coverted to octects before writing).