Closed SireeshaSiddineni closed 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)
First, obtain the content data of the file, and then unzip the data, finally decode the unzipped data to string.
let contentFromFile = try NSString(contentsOfFile: zipfile , encoding: String.Encoding.utf8.rawValue)
is not working for zip file
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
Because we need data to uncompress. We cannot unzip nothing.