Skip to content

How to decompress and write data from a .tgz file? #41

Closed Answered by tsolomko
owencraston asked this question in Q&A
Discussion options

You must be logged in to vote

The tgz file is actually tar.gz file, which means that this is a TAR archive that was afterwards compressed with GZip. So when you do this:

  let decompressedData = try! SWCompression.GzipArchive.unarchive(archive: tgzData)

you get a TAR archive that has to be further processed with either TarContainer.open or TarReader.

The error you're seeing is unrelated to the above: you are trying to write a file into an existing path, which is a directory. You have to specify a file name in the URL you are writing to. Data.write(to:) doesn't automatically append any file names to the path that was provided.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tsolomko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants