views:

27

answers:

0

I'd like to use the UIDocumentInteractionController (iOS 3.2 or higher) to display linked online files in a modal view with the option to open in external apps on the device.

I've figured out the coding to make this happen, but I'm being stymied by Google's links that do not disclose the direct file URL or file type, thus making it impossible for me to detect the appropriate filetypes to make the appropriate calls.

For this example, I'll just discuss PDF files. In particular, URLs of Gmail attachments, doc files on Google Docs and links via Google searches are all changed in some way (please note that I've removed the http:// from each of these links due to due a StackOverflow limitation):

  • Gmail URL of PDF attachment: mail.google.com/a/mydomain.com/?ui=2&ik=af1da6584d&view=att&th=12a0589e1f94e86c&attid=0.1&disp=attd&realattid=f_gbw4a7ql0&zw

This URL, when clicked, loads the PDF without issue in Safari and UIWebView, but I never see the actual link to the file.pdf.

  • Docs URL of PDF file: docs.google.com/uc?id=1uSYfY3r5m9zqX_-DB3XOh4YgGPiBtgF8ixGoFR5dwHCiXl2GMZgnkfpmGy-5&export=download&hl=en

This URL also leads to download of the appropriate PDF file, but I can't get the actual link.

  • Google Search URL of PDF file: www.google.com/m/url?ei=wCZLTMiIH5bdtgff0N-2Aw&gl=us&hl=en&q=http://www.irs.gov/pub/irs-pdf/fw4.pdf&resnum=1&source=mig&ved=0CA4QFjAA&usg=AFQjCNH-bseRw51OYADKvD6h9gEFAT38eA

This is the easiest because I can at least parse this link for what I need because it's clearly embedded within the link. Just clicking on the link will download the file, however.

Any ideas how I could easily detect the filetype and download the file for each of these links? Am I missing something here?