0

I need to open a file from web url and open in other apps that have installed in the device using UIDocumentInteractionController

var controller:UIDocumentInteractionController?

self.controller? = UIDocumentInteractionController.init(URL: (NSURL(string: self.filesUrl))!)

where self.filesUrl = self.filesDetailArrayResponse.valueForKey("url") as! NSArray is from the json response

But self.controller returning nil value

Dinesh Kumar
  • 165
  • 1
  • 14
  • can you tell me which file are you trying to open in `UIDocumentInteractionController` ? – CodeChanger Sep 13 '16 at 04:44
  • @Dhanesh The files of types like image files(.jpeg,.png), video(.mp4) and text file (.txt) which is stored in server and should be opened directly with other apps installed in device but should not save those files in local device and should be opened directly with other apps installed in the device.. – Dinesh Kumar Sep 13 '16 at 06:35
  • Did you find a solution for this please? – Ne AS Nov 10 '16 at 14:24

1 Answers1

4

It is not possible do it with web URL, the file must be in the local filesystem as a file URL. From the apple documentation:

UIDocumentInteractionController

var url: URL? { get set }

The URL identifying the target file on the local filesystem.

So how to solve it, download the file, the write it in the local filesystem and then give the local URL to the UIDocumentInteractionController (for example with: https://stackoverflow.com/a/16392475/1791179)

Community
  • 1
  • 1
txulu
  • 1,602
  • 16
  • 26