Ionic Framework将文本保存到blob文件中

时间:2021-08-12 22:58:30

I am currently running a service on phone that will continuously retrieve and store the data into my web-sql...

我目前正在手机上运行一项服务,该服务将不断检索并将数据存储到我的web-sql中......

However, it has since exceed 8,000 character counts and I would like to store the data into a blob file.

但是,它已超过8,000个字符数,我想将数据存储到blob文件中。

Is there any example available to use file-stream to store the data into a blob file and using file-reader to extract the data?

是否有任何示例可用于使用文件流将数据存储到blob文件中并使用文件读取器来提取数据?

Thank you!

1 个解决方案

#1


0  

Here is an example I worked on last time to create BlOB from services and save file in text format. This directly downloads the file.

这是我上次从服务创建BlOB并以文本格式保存文件的示例。这直接下载文件。

 var file = new Blob([Yourdata], {type: 'text/plain'});
 var timestamp = new Date().toUTCString();
 saveAs(file, "File Name " + timestamp + ".txt");

However, the first line creates the BLOB you want and you can further process it to fit your needs. It works fine in web-view.

但是,第一行创建了您想要的BLOB,您可以进一步处理它以满足您的需求。它在Web视图中工作正常。

And here is example to read file if you want to look at it. http://plnkr.co/edit/y5n16v?p=preview Hope this helps.

如果您想查看它,这里是读取文件的示例。 http://plnkr.co/edit/y5n16v?p=preview希望这会有所帮助。

#1


0  

Here is an example I worked on last time to create BlOB from services and save file in text format. This directly downloads the file.

这是我上次从服务创建BlOB并以文本格式保存文件的示例。这直接下载文件。

 var file = new Blob([Yourdata], {type: 'text/plain'});
 var timestamp = new Date().toUTCString();
 saveAs(file, "File Name " + timestamp + ".txt");

However, the first line creates the BLOB you want and you can further process it to fit your needs. It works fine in web-view.

但是,第一行创建了您想要的BLOB,您可以进一步处理它以满足您的需求。它在Web视图中工作正常。

And here is example to read file if you want to look at it. http://plnkr.co/edit/y5n16v?p=preview Hope this helps.

如果您想查看它,这里是读取文件的示例。 http://plnkr.co/edit/y5n16v?p=preview希望这会有所帮助。