How to get Mime type of a file in TDataType using an API?

Login to reply to this topic.
Fri, 2003-12-05 19:53
Joined: 2003-07-17
Forum posts: 28
Hi,

Is there a simple way to get the hidden mime type of a media file. Say, I download a file file.mp3 renamed as myfile over bluetooth and save it as a local file. later i want to know if CDocumentHandler can handle the file by calling the function myDocHandler.CanHandle(TDataType type).

To do this, i need to know the MIME type of "myfile".

Is there a simple function lile TDataType GetMimeType(TDes &filename) ?

I would appreciate anyone who can help me..

regards & thanks

murali

Mon, 2005-02-21 03:51
Joined: 2005-02-17
Forum posts: 16
How to get Mime type of a file in TDataType using an API?
I know this topic is rather old, but maybe this can be of use to someone anyway.

Code:
TDataType GetMimeTypeL(const TDesC& fileName)
{
TDataType type;
RFile File;
User::LeaveIfError(File.Open(iEikonEnv().FsSession(),fileName,EFileShareExclusive|EFileRead));

TBuf8<512> fileBuf;
File.Read(0,fileBuf);

File.Close();

RApaLsSession ls;
if (ls.Connect() == KErrNone)
{
TDataRecognitionResult rr;
ls.RecognizeData(fileName,fileBuf,rr);
   
if (rr.iConfidence != CApaDataRecognizerType::ENotRecognized)
type = rr.iDataType;
ls.Close();
}

return type;
}
  • Login to reply to this topic.