How can I read documents from other iOS apps? - iphone

I have an app which is similar to an FTP client. I can download various types of documents in it. (DOC, XLS, PDF, PPT etc)
Now, I want to read those documents in another application. For example: Suppose I download a PDF in my app, it is possible to read from AirSharing or File Magnet?

I don't think it's possible for other applications to access Library folders owned by other apps, and definitely not private application folders.
Document handling might handle what you want only to an extent - not the files that don't have their types registered to any app, and only at a one by one file basis, essentially duplicating the files as well.
If this is your app you are talking about, you can implement the Open In feature which is part of the Document Interaction in iOS, which will allow the user to access the file in any app that is registered to handle the extension/UTI.
In particular, these methods:
UIDocumentInteractionController
– presentOpenInMenuFromRect:inView:animated:
– presentOpenInMenuFromBarButtonItem:animated:

Related

With Chrome Apps soon to be removed, is there another way to edit a local file?

The Chrome Apps API has the very useful FileSystem API which allows a user to select a file for an app to edit (read and write changes to). However, with the entire Apps API soon to be removed, what other ways exists to edit a file on the local file system?
This is not an opinion-based question, I am asking for all conceivable alternatives.
Per https://developers.chrome.com/apps/migration:
Q: My app uses the chrome.fileSystem API to read and write user-specified files and / or directories. Can this be done on the open web?
A: In general, no. The open web can read single files that the user opens, but cannot retain access to those files, write to those files, or have any access to directories.
If it is critical for your app to read and write directories (e.g. it is a text editor with a folder view), you will need to either have a native helper app and extension combo, or create a native app.

What Files can iOS Apps use?

The situation: We would like to make an app that shows all files on an iOS Device
The system: iOS App, non jailbroken system
The question:
What files (and filetypes) are allowed to be accessed by every app (system-wide) ?
(PS: we won't do file-browser like actions like sub-folders, delete, etc .. )
UPDATE :
what you are trying to achieve is not possible because of the sandbox feature of the apps. though you can display certain file types using below description.
Previously Answered this
If I understand your question correctly, there is already a framework for what you are trying to achieve. It is called the quick look framework and supports these many file types...
A Quick Look preview controller can display previews for the following items:
iWork documents
Microsoft Office documents (Office ‘97 and newer)
Rich Text Format (RTF) documents
PDF files
Images
Text files whose uniform type identifier (UTI) conforms to the public.text type (see Uniform Type Identifiers Reference)
Comma-separated value (csv) files
you can have more info about it here...
You can't access anything other than your application folder. Your application is sandboxed and for good reasons (privacy, malware, etc...)
You can only access files within your application directory. Look here for a full explanation
If you don't mean files and just the content of the phone, there are APIs for
Photos
Contacts
Media from the Music app

How do I open a file with unknown associations in iOS?

I think it's rather impossible, but will ask anyway. My application uses file association to open some types of files. What I need is to make file associations within my app. For example I have some files in my app's Documents folder and when user wants to open that it would be a great idea to ask him in which application he would like it to open (like Mail app does).
It can possibly be done with URL schemes, but if I don't know what applications user has, it can't be used. So, is there any way to use the device's file associations within an application?
You should take a look at Document Interaction Programming Topics for iOS. It explains how you can use the UIDocumentInteractionController class to present the user a list of apps which support a given file.

Select a file on an iPhone

I want the user to select a file from an iPhone and upload to an HTTP server.
Example: The GoodReader application has this feature in it.
How can this be done?
You can't get all the files stored on the phone.
As the comment from Stephen Darlington states, your app is sandboxed and can only get to the files stored inside your app.
You could register your app to be able to open PDF, txt, doc and other files that you are interested in sending to your server and then users would be able to open these documents in your app. Once the files are inside your app you could then use any number of ways to upload them.
Please read the documentation here about registering your app to understand file types:
Registering the File Types Your App Supports
The file list would just be a UITableView, probably with a custom UITableViewCell.
There are a number of options for uploading data to a web service. The built-in way would be to use NSURLConnection. There are some open source frameworks that may be able to help but I have not used them.
The best way that I've found to upload images is to use the ASIHTTPRequest API. Here is a link on the documentation on POSTING data to a server. Download ASIHTTPRequest here and these are the setup instructions.
How to select a file depends on what kind of file you're trying to select. If you're trying to upload images you should look into a UIImagePickerController and UIImagePickerControllerDelegate. If not, you'll have to create a NSFileManager to search through your application's files.
NSFileManager Class reference:
http://developer.apple.com/iphone/library/documentation/cocoa/reference/foundation/Classes/NSFileManager_Class/Reference/Reference.html
Discovering Directory Contents:
– mountedVolumeURLsIncludingResourceValuesForKeys:options:
– contentsOfDirectoryAtURL:includingPropertiesForKeys:options:error:
– contentsOfDirectoryAtPath:error:
– enumeratorAtPath:
– enumeratorAtURL:includingPropertiesForKeys:options:errorHandler:
– subpathsAtPath:
– subpathsOfDirectoryAtPath:error:

(Iphone) associate an App to some file extension to open email attachments in Mail app

I found that some application, like "GoodReader" or "Docs to Go", once installed can be activated using the "Open in" function when opening an email attachment in the Mail App. How to add this function to have my App to be associated to some kind of documents (like pdf) ?
The idea is to have an easy way to get mail attachments to be used directly inside an app.
Edit: I found this document and think it fits my question:
Document Support
An application can now register the file types it supports with the system and receive notifications when a file of the given type needs to be opened. It does this by including the CFBundleDocumentTypes key in its Info.plist file. An application that registers one or more file types may also be expected to open files of those types at some point later. It does this by implementing the
application:didFinishLaunchingWithOptions:method in its application delegate and look for a file
in the UIApplicationLaunchOptionsURLKey key of the provided dictionary.
Complementing the ability to open files of known types is the addition of the
UIDocumentInteractionControllerclass in the UIKit framework. This class provides a user-based
interaction model for managing files that your application does not know how to open. The document
interaction controller provides options for previewing the contents of a file in place or opening it in another
application. Document interaction controllers are particularly useful for email applications or applications
that may download files from the network.
take a look at Custom URL Schemes and UIDocumentInteractionController. If you are looking to add the "open in" menu, the second link is what you need. If you are looking to register as a "PDF reader" this link (scroll to section about registering your app for certain types) should work iPad Programming Guide