1024jp / GzipSwift

Swift package that enables gzip/gunzip Data using zlib
MIT License
544 stars 134 forks source link

While zipping and unzipping why we need to pass data #39

Closed SireeshaSiddineni closed 5 years ago

1024jp commented 5 years ago

Because we need data to uncompress. We cannot unzip nothing.

SireeshaSiddineni commented 5 years ago

I have only zip file name. Can we pass the file path and unzip the data.Or else can you please help to read the zip file content so that I will pass the same data to unzip method.

My real time scenario is I need to send this zip file to server.but getting nil while trying together he content from the file.by using the below code.

let contentFromFile = try NSString(contentsOfFile: zipfile , encoding: String.Encoding.utf8.rawValue)

1024jp commented 5 years ago

First, obtain the content data of the file, and then unzip the data, finally decode the unzipped data to string.

SireeshaSiddineni commented 5 years ago

let contentFromFile = try NSString(contentsOfFile: zipfile , encoding: String.Encoding.utf8.rawValue)

is not working for zip file

1024jp commented 5 years ago

As I said, here is not the place to ask about general Swift programming.

This is the last. try:

let data = try Data(contentsOf: zippedFileURL)  // obtain the content data of the file
let unzippedData = try data.gunzipped()  // unzip the data
let string = String(data: unzippedData, encoding: .utf8)  // decode the unzipped data to string