3

I am writing an application that needs to recognize my custom mime type so that when such file is downloaded from a server my application will be launched. I read the great article of Brad on how to write a mime type recognizer under iOS at How do I associate file types with an iPhone application? and it works well if and only if the extensions of the file is also specified in the UTExportedTypeDeclarations / UTTypeTagSpecification section of my plist and the server serves the files with the same extension. If the server serves the file with a different extension or if no extensions are specified in the plist but the mime-type is matching, the following happens:

The browser (or the application that received the file) shows the correct icon of my file type with the correct [Open in myApplication] button but clicking on the button does nothing, my application is not launched and if it is running, no application:openURL:sourceApplication:annotation: message is sent.

Is there any way to write a file type recognizer based only on the mime-type, without a specific file extension?

Community
  • 1
  • 1
MrTJ
  • 13,064
  • 4
  • 41
  • 63

1 Answers1

0

this has been answered, you'd want to use NSURLRequest, this will allow you to get to the mimeType which you can use to determine the file extension as needed. the full code and additional hints and tips are available at this post:

https://stackoverflow.com/a/1401918/728261

Community
  • 1
  • 1
SeeCoolGuy
  • 81
  • 9
  • 1
    I am afraid you misunderstood the question. I am registering a new mime type in the system, and would like the system forwarding me those files (downloaded by the browser, mail attachments, etc) even if only their mime type is known, and the extension not. – MrTJ Aug 02 '12 at 15:06
  • so if it's your files, could you not create the files with a custom extension that you could register when your app is installed? – SeeCoolGuy Aug 02 '12 at 17:13
  • Yes, this could be a solution for iOS but I have to cooperate with different systems (mobile clients with other platforms, server infrastructure and HTTP, etc) and it would be very useful to get rid of the necessity of passing also the file extension. – MrTJ Aug 03 '12 at 10:29