I have been using the Synapse library to download files from the internet, but I have recently converted my application to use INDY instead and I am missing one of the nicer features in the Synapse library which is the ability to easily get the Mime-Type of a file that I was downloading from a server before saving it to my local machine. Does INDY have this feature and if so how do I go about accessing it?
相关问题
- Is there a Delphi 5 component that can handle .png
- Is there a way to install Delphi 2010 on Windows 2
- Is TWebBrowser dependant on IE version?
- iOS objective-c object: When to use release and wh
- DBGrid - How to set an individual background color
相关文章
- Best way to implement MVVM bindings (View <-> V
- Why my javascript code is not executing and says n
- Windows EventLog: How fast are operations with it?
- How to force Delphi compiler to display all hints
- Coloring cell background on firemonkey stringgrid
- HelpInsight documentation in Delphi 2007
- Can RTTI interrogate types from project code at de
- MIME type for directories in Android
You can issue an HTTP
HEAD
request and check theContent-Type
header. Before you actuallyGET
the file (download) :The
ContentType
you receive back depends on the web server implementation and is not guaranteed to be the same on each and every server.The other option, is to actually
GET
the file and save it's content to a memory stream such asTMemoryStream
(not to a local file). Indy provides an overload:Then you check the
Http.Response.ContentType
, and Save the stream to file:AStream.SaveToFile
.Not sure about the relevancy here, but note also that Indy can return/guess the mime type of a local file as well (given a file extension). with
GetMIMETypeFromFile
(usesIdGlobalProtocols
). See also here.Or you can build your function
And then call