在我的 flutter 应用程序中,我必须从远程服务器下载一个受密码保护的 zip
文件夹,然后导入我的应用程序中的 .sqlite
。
我正在尝试 archive
图书馆,但我当然愿意寻求更好的解决方案。
我使用了 ZipDecoder().decodeBytes()
方法的 password
参数,但它对我不起作用。
//inside the `onDone()` callback of an http request
Archive archive = ZipDecoder().decodeBytes(
_myDownloadedData,
password: "mySuperSecretPsw", //here I set the archive psw
);
Uint8List fileDbBytes = Uint8List.fromList(archive.first.content);
setAsWorkingDb(fileDbBytes);
上面代码段中的 archive.first.content
看起来仍然是加密的。我收到以下错误:
E/SQLiteLog(12256): (26) file is encrypted or is not a database
E/DefaultDatabaseErrorHandler(12256): Corruption reported by sqlite on database: /data/user/0/my.own.package/app_flutter/working_data.db
E/DefaultDatabaseErrorHandler(12256): deleting the database file: /data/user/0/my.own.package/app_flutter/working_data.db
最佳答案
你可以试试
Archive archive = ZipDecoder().decodeBytes(
_myDownloadedData,
verify: true,
password: "mySuperSecretPsw", )
关于 flutter 存档 : unzip password-protected folder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57107887/