PDA

View Full Version : Send Base64 encoded data



rmagro
29th October 2007, 16:02
Hi guys,

I have a file in wich I store data coded in Base64.

I want to read that data (that is I would like to put that in a buffer) and than send them
(the buffer) via http..

I already have a function which does the second part ..or rather it takes a buffer (char *)
and sent it via http, so my problem is related to prepare the data itself to be sent..

So far I tried various method to retrive this data from the file (base64 encoded) and all the time I send them, at destination I get the data with all the "+" simbol converted into a " " space.

So I am going to ask you..

Which is the best way to solve this problem?

Thank yoy very much in advance.

All the best

Roby

marcel
29th October 2007, 16:08
Maybe the problem is in the way you read the data... Do you read it as text or as binary?
You should read it as binary, wit ha QDataStream.

jpn
29th October 2007, 16:39
Btw, have you noticed QByteArray? It might be more convenient to use than char* and it also has helper methods toBase64() and fromBase64()... ;)

rmagro
29th October 2007, 17:04
Can you please give me an example o what you said..because from Qt assistant I found an example but id does not work..

Thank you

rmagro
29th October 2007, 17:05
I know, but the function I have to use takes char *

marcel
29th October 2007, 17:54
You have QDataStream::readRawData and QByteArray::data. They both work with char arrays.

jpn
29th October 2007, 17:58
I know, but the function I have to use takes char *
Well, you could still handle all the file reading and such with QByteArray and then simply pass QByteArray::data() to that function. Of course you can use char* if you want to. This was just a friendly suggestion. :)