
Originally Posted by
alav
Indeed, that was the case, and some missing new line signs as well. Thank you.
Now I am able to transfer all my data successfully. However, if I send my image encoded using the base64 algorithm, the webserver doesn't recognize it as an image... It is saved on the server, but it can't be read as JPG.
Here's how I put it in the request body:
_LIT8(KNewLine, "\n");
_LIT8(KPost1, "--1345234fsf342\n");
_LIT8(KPost2, "Content-Disposition: form-data; name=\"photo\"; filename=\"test.jpg\"\nContent-Transfer-Encoding: base64\n\n");
_LIT8(KPost3, "--1345234fsf342--\n");
tmp.Append(KPost1);
tmp.Append(KPost2);
tmp.Append(aPhoto);
tmp.Append(KNewLine);
tmp.Append(KPost3);
where aPhoto is a Ptr8 containing a base64 encoded photo.
If I send the base64 string directly, as text/plain, save it in a file on the webserver and use an external base64 decoder, the image is decoded correctly - so it is not a matter of encoding error.
I suppose that I am putting the image data in the request body in an incorrect way and because of that the webserver can't read it in a proper way, it just decodes it to a file of an unrecognizable format.
Are you able to spot any errors in my code?
Maciej
hi can u share with me on how u managed to get the right string representation for "aPhoto"?
thanks =)
Code:
RFileReadStream inputStream(iFile);
MStreamBuf* streamBuf;
aSize=aSize/500;
HBufC8* mediaFile;
mediaFile=HBufC8::NewLC(aSize);
TPtr8 bufferPtr(mediaFile->Des());
//iFile.Read(bufferPtr);
streamBuf=inputStream.Source();
TRequestStatus readStatus;
streamBuf->Read(bufferPtr,readStatus);
User::WaitForRequest(readStatus);
streamBuf->Close();
inputStream.Release();
i've tried this way but no luck....
i get some sort of string but when i use that to upload to my server the byte size seems too small...
pls help