WEB开发网
开发学院手机开发Symbian 开发 Symbian C++ Multipart/form-data 阅读

Symbian C++ Multipart/form-data

 2010-09-16 00:02:00 来源:WEB开发网   
核心提示:form-data; name='userfile'; filename='");_LIT8(KFileCompletion,"'"); _LIT(KContent2,"Content-Type: image/gif");_LIT(KCo
form-data; name='userfile'; filename='");_LIT8(KFileCompletion,"'"); _LIT(KContent2,"Content-Type: image/gif");_LIT(KContent3,"Content-Transfer-Encoding: binary");_LIT8(KDataEnd,"--AaB03x--"); iPostData = HBufC8::NewL(650+aPtr.Length()); TPtr8 iPostDataPtr = iPostData->Des();iPostDataPtr.Zero(); iPostDataPtr.Append(KCrlf);iPostDataPtr.Append(KDataStart);iPostDataPtr.Append(KCrlf);iPostDataPtr.Append(KContent);iPostDataPtr.Append(aFname);iPostDataPtr.Append(KFileCompletion);iPostDataPtr.Append(KCrlf);iPostDataPtr.Append(KContent2);iPostDataPtr.Append(KCrlf);iPostDataPtr.Append(KContent3);iPostDataPtr.Append(KCrlf);iPostDataPtr.Append(KCrlf);iPostDataPtr.Append(aPtr); //the file in binaryiPostDataPtr.Append(KCrlf);iPostDataPtr.Append(KDataEnd);iPostDataPtr.Append(KCrlf);

Submit the transaction

RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();AddHeaderL(hdr, HTTP::EUserAgent, KUserAgent);AddHeaderL(hdr, HTTP::EAccept, KAccept);AddHeaderL(hdr, HTTP::EContentType, KPostContentType); MHTTPDataSupplier* dataSupplier = this;iTransaction.Request().SetBody(*dataSupplier); iTransaction.SubmitL();

Implement DataSupplier functions

TBool CHTTPExampleEngine::GetNextDataPart(TPtrC8& aDataPart){ TBool retVal = EFalse; aDataPart.Set(iPostData->Des()); retVal = (aDataPart.Length() == 0); iDataAvailable=retVal; return retVal;} TInt CHTTPExampleEngine::OverallDataSize(){ if(iPostData) return iPostData->Length(); else return KErrNotFound ;} void CHTTPExampleEngine::ReleaseData(){ if(iDataAvailable) iTransaction.NotifyNewRequestBodyPartL();}

Any binary file can be uploaded with this upload code.

上一页  1 2 

Tags:Symbian Multipart form

编辑录入:coldstar [复制链接] [打 印]
赞助商链接