curl-users
Re: How to identify the file type
From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 18 Aug 2011 10:56:32 +0200 (CEST)
Date: Thu, 18 Aug 2011 10:56:32 +0200 (CEST)
On Thu, 18 Aug 2011, Bong Coronel wrote:
> I have a problem with identifying the type of the file being fetched using
> libcurl. Basically I would like to identify if a file is an image file or a
> pdf file. I don't think the content-type will be able to give me this
> information. Would anyone of you advice me how to do this in curl?
1. *nix-like operating systems offer a file command that identifies file type:
'man file' (and the associated /usr/share/misc/magic)
2. Browsers solve this problem (and more) using "content sniffing". There was
an effort going on to document how to do it:
http://tools.ietf.org/html/draft-abarth-mime-sniff-06
-- / daniel.haxx.se ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-users FAQ: http://curl.haxx.se/docs/faq.html Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2011-08-18