简体   繁体   English

Javascript web 基于浏览器的工具,用于从 gzip (tgz) 中提取本地文件

[英]Javascript web browser based tool to extract local files from gzip (tgz)

As part of a bigger log file analysis tool that I want to write in Javascript I need to extract text files (log files) from a tgz archive that are on the local hard drive.作为我想在 Javascript 中编写的更大的日志文件分析工具的一部分,我需要从本地硬盘驱动器上的 tgz 存档中提取文本文件(日志文件)。

I have a html page with a drag n drop field which provides the file in JS.我有一个带有拖放字段的 html 页面,它提供了 JS 文件。 I understood there is a decompression API in modern web browsers that I can use to decompress the gzip portion.我知道在现代 web 浏览器中有一个解压 API可以用来解压 gzip 部分。 My problem is: I cannot use the pipeThrough function on a file.我的问题是:我无法在文件上使用 pipeThrough function。 What is the most efficient way to do what I want to do?做我想做的事情最有效的方法是什么? Thanks谢谢

Sometimes it helps to write down the problem to solve it yourself:)有时把问题写下来自己解决会有所帮助:)

const decompressedReadableStream = file.stream().pipeThrough(new DecompressionStream('gzip'));

did the trick.成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM