Search code examples
iosurlfile-type

How do I find out type of file from URL?


If a URL ends with just a string of characters, and no extension. i.e.:

http://example/1234567890

...and I know contains either a PNG, JPG or GIF. How do I find out which one it is without downloading the whole file. I'm asking because I need to do something completely different with it if it's a GIF.


Solution

  • Make a header request and look for the mime type as was posted here:

    Get HTTP header fields only on iPhone

    Complete List of MIME Types