Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uncompress tar stream (file or HTTP) to any destination #52

Closed
mc-hamster opened this issue Jan 2, 2022 · 6 comments
Closed

uncompress tar stream (file or HTTP) to any destination #52

mc-hamster opened this issue Jan 2, 2022 · 6 comments

Comments

@mc-hamster
Copy link
Contributor

Hi!

I see methods to uncompress .tar.gz and .gz streams but no existing methods to uncompress just tar stream and save it to the file system. Is there a way to do this with the library now?

Thanks!

@tobozo
Copy link
Owner

tobozo commented Jan 2, 2022

hey, thanks for your feedback.

Indeed there was no stream method for tarExpander, I've fixed that on branch 1.1.4 and will produce a new release soon.

Thanks for pointing out the lack of stream support for tar 👍

tobozo added a commit that referenced this issue Jan 2, 2022
@tobozo
Copy link
Owner

tobozo commented Jan 2, 2022

there's a new release implementing tarStreamExpander, it'll propagate soon in Arduino registry and is already available in platformio registry.

    bool tarStreamExpander( Stream *stream, size_t streamSize, fs::FS &destFS, const char* destFolder );

I'm closing this issue, feel free to reopen and/or add followup.

@tobozo tobozo closed this as completed Jan 2, 2022
@mc-hamster
Copy link
Contributor Author

just wow, thanks mate!

@mc-hamster
Copy link
Contributor Author

@tobozo

I updated an example with the new method and can't seem to have it write to the file system.

https://github.com/mc-hamster/ESP32-targz/tree/master/examples/ESP32/Unpack_tar_gz_stream

Could I kindly ask that you look this over? It's probably something glaringly obvious.

I'll send a PR for this example after some cleanup.

@tobozo
Copy link
Owner

tobozo commented Jan 2, 2022

All I can think of is it doesn't like -1 as a stream size.

If the web server you're downloading the file from sends the Content-Length headers you can get the size as follows:

      String contentLengthStr = http.header("Content-Length");
      contentLengthStr.trim();
      int64_t streamSize = -1;
      if( contentLengthStr != "" ) {
        streamSize = atoi( contentLengthStr.c_str() );
      }
      if (!TARUnpacker->tarStreamExpander(streamptr, streamSize, tarGzFS, "/"))
      // ...

@mc-hamster
Copy link
Contributor Author

@tobozo Rock on! I'll submit a PR for the example to support this shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants