My requirement is to provide a nodejs service, compress the network resources, and then provide it to the front-end page to download.
While downloading network resources become compressed, can provide a better user experience.
My code is like follows
const tarStream = new compressing.tar.Stream();
tarStream.addEntry(stream, {
relativePath: fileName,
size: contentLength, // from http.request response headers content-length
});
I need to request multiple resources. I must set size. But the size can only be obtained after the request returns. I can't wait all resources request returns, It will take too much time.
If when the first request returns. then I send the secound request and do addEntry after secound request returns. Compression will end early. The second resource will not be compressed.
I need to be able to actively control the end of compression.
And I tried to modify the source code as follows
/lib/tar/stream.js
My requirement is to provide a nodejs service, compress the network resources, and then provide it to the front-end page to download. While downloading network resources become compressed, can provide a better user experience. My code is like follows
I need to request multiple resources. I must set size. But the size can only be obtained after the request returns. I can't wait all resources request returns, It will take too much time. If when the first request returns. then I send the secound request and do
addEntry
after secound request returns. Compression will end early. The second resource will not be compressed. I need to be able to actively control the end of compression. And I tried to modify the source code as follows/lib/tar/stream.js
When I do
addEntry
all resource.This way I can fulfill my needs. It is recommended to modify the source code and add a manual trigger to complete the addition of all resources.
Thanks.