Post

Replies

Boosts

Views

Activity

How to convert data(Type Data) to a zip file(Type File) in swift 4 and cocoa for Mac OS App?
Hi there. I am developing a mac os application where i have to convert the data from server API to a zip file. The API is returning a zip file itself in encoded format of type Data, but i want to convert that data to a zip file and want to store in the disk.CODE:______ func DownloadExamZip(){ let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:5000/api/DownloadExamZip/EX0000018/ST000000195/874059")! as URL) request.httpMethod = "GET" let AuthorizationToken = "Hidden" request.setValue("application/x-www-form-urlencoded; charset=utf-8", forHTTPHeaderField: "Content-Type") request.setValue(AuthorizationToken, forHTTPHeaderField: "Authorization") let task = URLSession.shared.dataTask(with: request as URLRequest) { data, response, error in do { guard data != nil else { print("data is nil") return } //Here i want to convert the type data to a zip file } catch { print("Error -> \(error)") } } task.resume() } Can anyone help me to convert that data into a zip file please. I also have to store that file in the disk.
13
0
8.8k
Mar ’21