How to get file type in ios of a file that has been stored in a Data object?

Is there a function or class in iOS that allows me to distinguish a file's type after I've put it into a Data object, so that my code can decide what to do with the file depending on whether it is a video, an image, or an audio file? I am using Swift.

Replies

It might be much simpler to retain the file information up front.


Trying to identify what a file is from its content is a significantly difficult problem.