Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

hi,

i am useing following code to upload .qcp file to the server.

 

ISHELL_CreateInstance( pApp->m_pIShell, AEECLSID_WEB, (void**)&m_pweb);

 

ISHELL_CreateInstance(pApp->m_pIShell, AEECLSID_SOURCEUTIL, (void**)&m_psource_utility);

 

ISHELL_CreateInstance(pApp->piShell,AEECLSID_FILEMGR,(void**)&m_pIFileMgr);

 

m_pIFile=IFILEMGR_OpenFile(m_pIFileMgr,"recorde.qcp",_OFM_READ);

 

ISOURCEUTIL_SourceFromAStream(m_psource_utility,(IAStream*)m_pIFile,&m_pISource);

 

CALLBACK_Init( &(m_paee_callback),gotResponse,pApp->m_pWebCommuniction);

 

                    int i=0;

                    WebOpt aw[11];

                    aw[i].nId=WEBOPT_HANDLERDATA;

                    aw[i].pVal=(void*)pApp->m_pWebCommuniction;

                    i++;

                    aw[i].nId=WEBOPT_METHOD;

                    aw[i].pVal=(void*)"POST";

                    i++;

                    aw[i].nId=WEBOPT_BODY;

                    aw[i].pVal=m_pISource;

                    i++;

                    aw[i].nId=WEBOPT_END;

                    IWEB_AddOpt(m_pweb,aw);

                    IWEB_GetResponse(m_pweb,(m_pweb,&m_pweb_response,&m_paee_callback,URL,                        WEBOPT_CONTENTLENGTH,m_pInfo.dwSize,                        WEBOPT_STATUSHANDLER,gotStatus,                        WEBOPT_CONNECTTIMEOUT,-1,                        WEBOPT_FLAGS,WEBREQUEST_FORCENEWCONN,                        WEBOPT_END));

 

 

if i am sending Text file then sent data successfully convrted in to text file on server side.

but if i am sending QCP file then sent data is not properly converted in to .qcp file on server side.

is it correct way to upload the qcp file.

and if it is not correct  plz show me the correct way to upload qcp file.

Thanks.

 

 

 

Please Reply.......

Please Reply.......

After loading the data from a file you should URL encode the file before passing it as a data to POST request. A text file may be working because it contains all ASCII chars.
try doing somthing as below:
 
 
IPeek  *pIPeek;ISourceUtil *pSourceUtil;ISource  *pISource = NULL;
//File is read into buffer "buff" & pnInLen is the length of the data.
ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_WEBUTIL,(void**)&pWebUtil);
IWEBUTIL_UrlEncode(pWebUtil, (const char*)buff, &pnInLen, encodedBuff, &pnOutLen);
if(ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_SOURCEUTIL, (void **) &pSourceUtil ) != SUCCESS) {
 DBGPRINTF("**** Source Util Inst Failed ****");
 status = FALSE;
}
else {
         ISOURCEUTIL_PeekFromMemory(pSourceUtil, encodedBuff, pnOutLen, 0, 0, &pIPeek);
 }
}
//pWeb->m_FinalUrl has the URL to POST on.
if(pIPeek && pWeb->m_FinalUrl){    CALLBACK_Init(&pWeb->m_CallBack, ReadWebResponse, pWeb);
  IWEB_GetResponse(pWeb->m_pIWeb,(pWeb->m_pIWeb, &pWeb->m_pIWebResp,&pWeb->m_CallBack,
pWeb->m_FinalUrl,
          WEBOPT_HANDLERDATA, pWeb,
//setting content type is almost mandatory for a "POST" request
          WEBOPT_HEADER, "Content-type: application/atom+xml\r\n",
          WEBOPT_HEADERHANDLER, headerHandler,
          WEBOPT_STATUSHANDLER, WebStatusNotification,
          WEBOPT_METHOD, "POST",
          WEBOPT_BODY, pIPeek,
          WEBOPT_CONTENTLENGTH, pnOutLen,
//below option is required if on secuer connection only, has no effect on a HTTP connection
  WEBOPT_DEFAULTS, (void*)piroot,
          WEBOPT_END));
}
 

After loading the data from a file you should URL encode the file before passing it as a data to POST request. A text file may be working because it contains all ASCII chars.
try doing somthing as below:
 
 
IPeek  *pIPeek;ISourceUtil *pSourceUtil;ISource  *pISource = NULL;
//File is read into buffer "buff" & pnInLen is the length of the data.
ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_WEBUTIL,(void**)&pWebUtil);
IWEBUTIL_UrlEncode(pWebUtil, (const char*)buff, &pnInLen, encodedBuff, &pnOutLen);
if(ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_SOURCEUTIL, (void **) &pSourceUtil ) != SUCCESS) {
 DBGPRINTF("**** Source Util Inst Failed ****");
 status = FALSE;
}
else {
         ISOURCEUTIL_PeekFromMemory(pSourceUtil, encodedBuff, pnOutLen, 0, 0, &pIPeek);
 }
}
//pWeb->m_FinalUrl has the URL to POST on.
if(pIPeek && pWeb->m_FinalUrl){    CALLBACK_Init(&pWeb->m_CallBack, ReadWebResponse, pWeb);
  IWEB_GetResponse(pWeb->m_pIWeb,(pWeb->m_pIWeb, &pWeb->m_pIWebResp,&pWeb->m_CallBack,
pWeb->m_FinalUrl,
          WEBOPT_HANDLERDATA, pWeb,
//setting content type is almost mandatory for a "POST" request
          WEBOPT_HEADER, "Content-type: application/atom+xml\r\n",
          WEBOPT_HEADERHANDLER, headerHandler,
          WEBOPT_STATUSHANDLER, WebStatusNotification,
          WEBOPT_METHOD, "POST",
          WEBOPT_BODY, pIPeek,
          WEBOPT_CONTENTLENGTH, pnOutLen,
//below option is required if on secuer connection only, has no effect on a HTTP connection
  WEBOPT_DEFAULTS, (void*)piroot,
          WEBOPT_END));
}