0

I am using the owner accepted best answer in Compress directory to tar.gz with Commons Compress for my project.

I am able to create the .tar.gz file on the server, but I am unable to download it locally.

    ...
    File f = new File(path);
    System.out.println(f.exists());
    String entryName = base + f.getName();
    TarArchiveEntry tarEntry = new TarArchiveEntry(f, entryName);
    tOut.putArchiveEntry(tarEntry);

    if (f.isFile()) {
        IOUtils.copy(new FileInputStream(f), tOut);
        tOut.closeArchiveEntry();
    ...

Any suggestions on what can be done with tOut or after IOUtils.copy(new FileInputStream(f), tOut); to download the .tar.gz file locally. Currently its being generated in path. Thanks

user1971376
  • 93
  • 1
  • 4
  • 10
  • It might help if we even knew what `tOut` was. This question is entirely too vague. – Elliott Frisch Aug 25 '22 at 22:13
  • It's probably going to be safer to generate the tar file first, write it to a web response then possibly delete the file if storage is an issue – g00se Aug 25 '22 at 22:43
  • @ElliottFrisch tOut is `TarArchiveOutputStream`. Aplogies for the vagueness, basically I want the program to automatically download the created .tar.gz file from the server to my machine locally – user1971376 Aug 26 '22 at 01:43

0 Answers0