Can I verify Data if image using foundation framework only

131 views Asked by At

Is it possible, using swift, to verify data: Data is image using Foundation.framework only?

Nothing else from macOS or iOS is available as this is for Server side project only (Vapor)

1

There are 1 answers

0
tanner0101 On BEST ANSWER

If all you have is the byte array, this might help: Determine MIME type from NSData?.

If you're uploading through multipart, you should have access to the filename (and possibly other data) that you could use to detect whether it's an image. Although this could be spoofed.

Client side validation might also be useful here.