NoteZ_技术博客 NoteZ_技术博客
🏠 首页
  • 📚 Web技术
  • 📋 Npm笔记
  • 📑 Markdown
  • 📄 Git笔记
  • 📝 Nginx文档
  • 📓 Linux文档
  • 📖 技术文档
  • 📜 其他文档
  • 🧊 NodeJs
  • 🎡 Express
  • 🔥 Rust
  • 🎉 Koa2
  • 🍃 MongoDB
  • 🐬 MySql
  • 🥦 Oracle
  • 🍁 Python
  • 🍄 JavaScript
  • 🌰 CSS
  • 🧄 HTML
  • 🥑 Canvas
  • 🌽 Nuxt
  • 🍆 React
  • 🥜 Vue
  • 🧅 TypeScript
  • 🌶️ AI
  • 📘 分类
  • 📗 标签
  • 📙 归档
⚜️ 在线编辑 (opens new window)
  • 📁 站点收藏
  • 📦 前端组件库
  • 📊 数据可视化
  • 🌈 开源插件
  • 🎗️ 关于我
  • 🔗 友情链接
GitHub (opens new window)

NoteZ_技术博客

前端界的小学生
🏠 首页
  • 📚 Web技术
  • 📋 Npm笔记
  • 📑 Markdown
  • 📄 Git笔记
  • 📝 Nginx文档
  • 📓 Linux文档
  • 📖 技术文档
  • 📜 其他文档
  • 🧊 NodeJs
  • 🎡 Express
  • 🔥 Rust
  • 🎉 Koa2
  • 🍃 MongoDB
  • 🐬 MySql
  • 🥦 Oracle
  • 🍁 Python
  • 🍄 JavaScript
  • 🌰 CSS
  • 🧄 HTML
  • 🥑 Canvas
  • 🌽 Nuxt
  • 🍆 React
  • 🥜 Vue
  • 🧅 TypeScript
  • 🌶️ AI
  • 📘 分类
  • 📗 标签
  • 📙 归档
⚜️ 在线编辑 (opens new window)
  • 📁 站点收藏
  • 📦 前端组件库
  • 📊 数据可视化
  • 🌈 开源插件
  • 🎗️ 关于我
  • 🔗 友情链接
GitHub (opens new window)
  • Express

  • Koa2

  • MongoDB

  • MySql

  • NodeJs

    • 2021 年值得使用的 Node.js 框架
    • CentOS 7上安装 Node.js 的 4 种方法
    • Linux 下安装 NodeJs 以及版本的升级和降级
    • node 中 path 模块 normalize 函数格式化路径
    • Node 中 使用 fs.stat() 读取文件状态
    • Node 中使用 compressing 压缩文件夹为 zip 文件
    • Node 中的实现 EventEmitter (event)方法
    • Node 代理 Demo 示例
    • node 判断文件或文件夹是否存在
    • node 复制文件的五种方式
    • Node 常用模块之 fs-extra
    • node 操作 mongodb 数据库备份与还原-示例代码
    • node 获取请求 ip
    • Node 读取和写入 json 文件
    • Node 递归或 mkdirp 创建多层目录
    • Node 遍历目录输出树形文件目录结构
    • Node(publish-sftp)命令上传本地文件到服务器
    • Node.js 中使用 compressing 实现zip文件的解压,解决文件名中文乱码
    • node.js 读取文件目录下的所有读取文件目录
    • Node.js把前台传来的 base64 码转成图片
    • nodeJs + vueJs 实现大文件分片上传
    • NodeJs 使用 jszip 或者 zip-dir 压缩文件夹(zip)
    • NodeJs 利用 jszip 压缩文件、文件夹,以及解压压缩文件中的文件
    • NodeJs 实现简单 WebSocket 即时通讯
    • NodeJs 框架 Express 的两种使用方式
    • NodeJs与Nginx获取客户端真实IP方法
    • NodeJs之大文件断点下载
    • NodeJS使用node-fetch下载文件并显示下载进度
    • NodeJs将图片进行压缩生成缩略图
    • nodejs递归读取所有文件
    • Node中复制文件的四种方法总结
    • node中的读取流createReadStream、写入流createWriteStream和管道流pipe
    • Node开发笔记
    • Node递归创建多层目录并写入文件
    • Node递归创建文件夹
    • PM2配置文件的使用、管理多个Node.js项目
    • 使用 koa-generator 快速搭建 Koa2 项目
    • 使用 pm2 部署 nodejs 项目
    • 使用 supervisor 自动重启 NodeJs 提高开发效率
    • 使用node反向代理解决跨域问题
    • 使用node实现保存(上传)图片的功能
    • 使用Node搭建超高压缩比的图片(webp)压缩服务
    • 前端部署从静态到node再到负载均衡
    • 在 NodeJs 中使用 compressing 压缩和解压缩文件或文件夹
      • 下载安装 compressing 包
      • 压缩文件
      • 压缩文件夹
      • 解压文件或文件夹
      • 官方文档
    • 在 nodejs 执行 shell 指令
    • 基于 Node 生成 vue 模板文件
    • 如何使用 Nodejs 备份 MongoDB 数据
    • 如何使用NodeJs实现base64和png文件相互转换
    • 如何在 Linux 服务器上使用 Nodejs 连接远程 Oracle 数据库
    • 混淆、编译 Node.js 源代码的几种方法
    • Node.js包之archiver压缩打包文件或目录为zip格式
    • node.js获取目录内所有文件大小总和
    • NodeJs 中使用 resize-img 制作缩略图
    • nodeJS中的http模块基本介绍
    • nodejs图片处理工具gm用法
    • node使用ffmpeg将swf转mp4 截取mp4视频第一帧为jpg图片
    • 如何在Node.js中执行shell命令
    • NodeJs 中复制(拷贝)文件或文件夹的多种方式
    • 在 NodeJs 中使用 archiver 压缩超大文件夹
    • Node.js 中使用 ssh2-sftp-client 上传文件并实时获取速率大小和进度
    • Node.js 中使用 ssh2-sftp-client 上传文件到服务器示例
    • node 使用 ssh2-sftp-client 实现 FTP 的文件上传和下载功能
    • ssh2-sftp-client 上传文件夹时获取上传速度和文件夹大小
    • 基于 node 使用 UDP 上传文件示例
    • 利用Node.js监控文件变化并使用sftp上传到服务器
    • 利用 Node 监控文件夹或文件夹变化可用的 npm 包汇总
    • NodeJS获取当前目录、运行文件所在目录、运行文件的上级目录
    • Node与GLIBC_2.27不兼容解决方案
  • Oracle

  • Rust

  • Python

  • 后端开发
  • NodeJs
NoteZ
2019-04-19
目录

在 NodeJs 中使用 compressing 压缩和解压缩文件或文件夹

nodejs 中使用compressing处理对文件或文件夹的压缩和解压缩支持 tar、gzip、tgz、zip 这四种压缩格式。下面以zip为例(其他格式的使用方式一样)。

# 下载安装 compressing 包

npm i compressing --save
1

# 压缩文件

const compressing = require('compressing');
compressing.zip.compressFile('./test.js', 'test.zip').then(res => {
  console.log(res);
}).catch(err => {
  console.log(err);
}) 
1
2
3
4
5
6

# 压缩文件夹

const compressing = require('compressing'); compressDir 的第一个参数为需要进行压缩的文件夹, 第二个参数为输出的zip文件

compressing.zip.compressDir('./test', 'test.zip').then(res => {
  console.log(res);
}).catch(err => {
  console.log(err);
})
1
2
3
4
5

# 解压文件或文件夹

uncompress的第一个参数为需要解压的zip文件,第二个参数为解压内容输出到哪个文件夹

const compressing = require('compressing');
compressing.zip.uncompress('aa.zip', '').then(res => {
  console.log(res);
}).catch(err => {
  console.log(err);
})
1
2
3
4
5
6

# 官方文档

GitHub:https://github.com/node-modules/compressing (opens new window)

#NodeJs#Compressing
上次更新: 2024/01/30, 00:35:17
前端部署从静态到node再到负载均衡
在 nodejs 执行 shell 指令

← 前端部署从静态到node再到负载均衡 在 nodejs 执行 shell 指令→

最近更新
01
Gitea数据备份与还原
03-10
02
Linux 中使用 rsync 同步文件目录教程
03-10
03
Linux 使用 rsync 互相传输同步文件的简单步骤
03-08
更多文章>
Theme by Vdoing | Copyright © 2019-2025 NoteZ,All rights reserved | 冀ICP备2021027292号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式