0
votes

I downloaded file from network, but in advance I don't know what type of file, I name it as PDF file, thus destroying some files, I use QLPreViewController 's method “+ canPreviewItem” judging whether the file can be previewed, in my mind if the pdf file is broken(QLPreViewController actually can’t preview), it will return NO. but it always returns yes, how do I can judge whether the file can be previewed ? Can you give me some help ?

1
Why are you naming a file with a PDF extension even if the file isn't a PDF?rmaddy
My server returns three format file to me, but did not return any file information, I can only assume returns are PDF files.user3304216
Wouldn't it be better to fix your server to return a file with the proper extension?rmaddy
There is no other option to solve my problem? Now fix the server is not a good choice.user3304216
Inspect the content of the file to determine its type. Update the extension based on that.rmaddy

1 Answers

0
votes

+[QLPreviewController canPreviewItem:] is just telling you, based on the UTI of the item argument, if Quick Look knows how to display this UTI or not.

It is not doing any introspection of the item (which would be very costly).

You can't escape fixing your server to return an appropriate file extension and MIME type, unfortunately.