回复
HarmonyOS应用API-zlib.zipFile
鸿蒙时代
发布于 2022-11-7 16:06
浏览
0收藏
Api: zlib.zipFile
版本适配:Api7
作用:压缩接口
示例代码:
//【压缩文件 例子1】
import zlib from '@ohos.zlib'
var inFile = "/xxx/filename.xxx";
var outFile = "/xxx/xxx.zip";
var options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
zlib.zipFile(inFile, outFile, options).then((data) => {
console.log("zipFile result:" + data);
}).catch((err)=>{
console.log("catch((err)=>" + err);
});
// 【压缩文件夹 例子2】
import zlib from '@ohos.zlib'
var inFile = "/xxx/xxx";
var outFile = "/xxx/xxx.zip";
var options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
zlib.zipFile(inFile , outFile, options).then((data) => {
console.log("zipFile result:" + data);
}).catch((err)=>{
console.log("catch((err)=>" + err);
});
标签
HarmonyOS应用API-zlib.zipFile.docx 16.87K 14次下载
赞
收藏
回复
相关推荐