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

Developer

Forums

Forums:

Hi,
I have few questions regarding IWEB and file transfer to a HTTP or FTP server.
- is it possible to upload file from handset to a HTTP/FTP server using IWEB and HTTP POST?
- If yes, how? Are there any sample codes?
- If no, then how this can be accomplished? Are there any sample codes?

Thank you,

Mustafa

yes this is possible.
You can do the following:
1. Create a source utility interface
ISourceUtil *piSourceUtil = 0;
Status = ISHELL_CreateInstance(pApplet->a.m_pIShell, AEECLSID_SOURCEUTIL, (void **)&piSourceUtil);
2. Open your file using IFileMgr and IFile interface. IFile interface is derived from IASTREAM interface.
3. Now use ISOURCEUTIL_SourceFromAStream interface, pass IFILE handler you get from step 2 in the second parameter. This API will return you the source pointer (3rd parameter) which can be used as your http post data body.
ruben

yes this is possible.
You can do the following:
1. Create a source utility interface
ISourceUtil *piSourceUtil = 0;
Status = ISHELL_CreateInstance(pApplet->a.m_pIShell, AEECLSID_SOURCEUTIL, (void **)&piSourceUtil);
2. Open your file using IFileMgr and IFile interface. IFile interface is derived from IASTREAM interface.
3. Now use ISOURCEUTIL_SourceFromAStream interface, pass IFILE handler you get from step 2 in the second parameter. This API will return you the source pointer (3rd parameter) which can be used as your http post data body.
ruben

Thanks.

Thanks.

Hi,
Trying to use IWEB to post an image file but keep getting HTTP error - 406
Here is the code I'm using , what am I doing wrong?? :rolleyes:
int CHttpNet::Send(char* filename, void* pUserData)
{
m_pUserData = pUserData;
m_bIsCanceled = FALSE;
const char* pHeaderBuff = m_sRqstHeaderBuff;
const char* pUrl = m_sUrl;
InitIWeb();
InitCallback(m_Cb, CallSendCompleted);
ISourceUtil * pISourceUtil=NULL;
FileInfo fileInfo;
if (ISHELL_CreateInstance(m_pApp->pIShell(), AEECLSID_SOURCEUTIL, (void **)&pISourceUtil) == SUCCESS)
{
if ((m_pIFile = IFILEMGR_OpenFile(m_pApp->pIFileMgr(), filename, _OFM_READ)) == NULL)
return FALSE;
if ( SUCCESS != IFILE_GetInfo(m_pIFile, &fileInfo ) )
return FALSE;
if ( SUCCESS != ISOURCEUTIL_SourceFromAStream(pISourceUtil, (IAStream *)m_pIFile, &m_pPostSource))
return FALSE;
ISOURCEUTIL_Release(pISourceUtil);
}
IWEB_GetResponse(m_pWeb, (m_pWeb, &m_pWebResp, &m_Cb,
m_sUrl,
WEBOPT_HEADER, pHeaderBuff,
WEBOPT_METHOD, "POST",
WEBOPT_DEFAULTS, m_pWebOpts,
WEBOPT_CONNECTTIMEOUT, m_nTimeout,
WEBOPT_BODY, m_pPostSource,
WEBOPT_CONTENTLENGTH, fileInfo.dwSize,
WEBOPT_HANDLERDATA, this,
WEBOPT_HEADERHANDLER, (PFNWEBHEADER)CallHandleHeader,
//WEBOPT_USERAGENT, (const char *)m_sUserAgent,
WEBOPT_END));
return SUCCESS;

Thanks
Pronto

Hi,
Trying to use IWEB to post an image file but keep getting HTTP error - 406
Here is the code I'm using , what am I doing wrong?? :rolleyes:
int CHttpNet::Send(char* filename, void* pUserData)
{
m_pUserData = pUserData;
m_bIsCanceled = FALSE;
const char* pHeaderBuff = m_sRqstHeaderBuff;
const char* pUrl = m_sUrl;
InitIWeb();
InitCallback(m_Cb, CallSendCompleted);
ISourceUtil * pISourceUtil=NULL;
FileInfo fileInfo;
if (ISHELL_CreateInstance(m_pApp->pIShell(), AEECLSID_SOURCEUTIL, (void **)&pISourceUtil) == SUCCESS)
{
if ((m_pIFile = IFILEMGR_OpenFile(m_pApp->pIFileMgr(), filename, _OFM_READ)) == NULL)
return FALSE;
if ( SUCCESS != IFILE_GetInfo(m_pIFile, &fileInfo ) )
return FALSE;
if ( SUCCESS != ISOURCEUTIL_SourceFromAStream(pISourceUtil, (IAStream *)m_pIFile, &m_pPostSource))
return FALSE;
ISOURCEUTIL_Release(pISourceUtil);
}
IWEB_GetResponse(m_pWeb, (m_pWeb, &m_pWebResp, &m_Cb,
m_sUrl,
WEBOPT_HEADER, pHeaderBuff,
WEBOPT_METHOD, "POST",
WEBOPT_DEFAULTS, m_pWebOpts,
WEBOPT_CONNECTTIMEOUT, m_nTimeout,
WEBOPT_BODY, m_pPostSource,
WEBOPT_CONTENTLENGTH, fileInfo.dwSize,
WEBOPT_HANDLERDATA, this,
WEBOPT_HEADERHANDLER, (PFNWEBHEADER)CallHandleHeader,
//WEBOPT_USERAGENT, (const char *)m_sUserAgent,
WEBOPT_END));
return SUCCESS;

Thanks
Pronto