I am trying to download an image file using the HTTP API. I am able to successfully download and display a text file.
However, when I download an image file , the file gets downloaded but the image says no preview available also if i try to download an audio file , the file gets downloaded but cannot be played.In other words any binary file I download is not usable.
For example, given below is the code when trying to download a bmp file called someimage.bmp.
My GetRequestL() function defined in the HTTP Engine is as follows :
where KUserAgent is defined as : _LIT8(KUserAgent, "HTTPExample (1.0)");
void CHTTPExampleEngine::GetRequestL(const TDesC& aUri)
// Parse the URI
// Create the transaction
iTransaction = iSession.OpenTransactionL(iUriParser, *this,
// Set transaction headers
RHTTPHeaders headers = iTransaction.Request().GetHeaderCollection();
AddHeaderL(headers, HTTP::EUserAgent, KUserAgent);
AddHeaderL(headers, HTTP::EAccept, KAccept);
// Submit the request
and KAccept is defined as _LIT8(KAccept, "*/*");
My ResponseReceivedL() function in the observer class is as follows :
DES_AS_8_BIT is defined as : #define DES_AS_8_BIT(str) (TPtrC8((TText8*)((str).Ptr()), (str).Size())) for converting 16 bit data to 8 bit.
void CHTTPExampleAppUi::ResponseReceivedL(const TDesC& aResponse)
iAppContainer->SetTextL(_L("Download Complete")); //Show message in Rich Text Editor
//Write to file
if(err != KErrNone)
iLog.WriteFormat(_L("Error = %d"),err);
I have tried using audio/* , image/* etc also as the value for KAccept but it still does not work.Do I need to save the downloaded binary file in a different way than the way I am doing above ?
Thanks a lot