1
@IBAction func clickedViewData(_ sender: Any) {
    let fileManager = FileManager.default
    let documentoPath = (self.getDirectoryPath() as NSString).appendingPathComponent("zip_2MB.zip")
    if fileManager.fileExists(atPath: documentoPath){
        let documento = NSData(contentsOfFile: documentoPath)
        let activityViewController: UIActivityViewController = UIActivityViewController(activityItems: [documento!], applicationActivities: nil)
        activityViewController.popoverPresentationController?.sourceView=self.view
        present(activityViewController, animated: true, completion: nil)
    }
    else {
        print("document was not found")
    }
}

i have one Zip file i want to share as a .zip directly..but cant get proper solution to share .zip file..when i share file its share as data file.. i read some documents but cant get proper way for share zip file in activity controller.. please help to solve this problem.

Thank You

Milan Varasada
  • 300
  • 1
  • 11

1 Answers1

1
let fileManager = FileManager.default
        let documentoPath = ("self.getDirectoryPath()" as NSString).appendingPathComponent("zip_2MB.zip")
        let documento = NSData(contentsOfFile: documentoPath)


        var url = URL(fileURLWithPath: NSTemporaryDirectory() + ("My File.txt"))
        documento?.write(to: url, atomically: false)

        // create activity view controller
        var activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
Milan Varasada
  • 300
  • 1
  • 11