本文整理汇总了C++中RemoteFilename::setIp方法的典型用法代码示例。如果您正苦于以下问题:C++ RemoteFilename::setIp方法的具体用法?C++ RemoteFilename::setIp怎么用?C++ RemoteFilename::setIp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RemoteFilename
的用法示例。
在下文中一共展示了RemoteFilename::setIp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: downloadFile
void CFileSpraySoapBindingEx::downloadFile(IEspContext &context, CHttpRequest* request, CHttpResponse* response)
{
try
{
StringBuffer netAddressStr, osStr, pathStr, nameStr;
request->getParameter("NetAddress", netAddressStr);
request->getParameter("OS", osStr);
request->getParameter("Path", pathStr);
request->getParameter("Name", nameStr);
#if 0
StringArray files;
IProperties* params = request->queryParameters();
Owned<IPropertyIterator> iter = params->getIterator();
if (iter && iter->first())
{
while (iter->isValid())
{
const char *keyname=iter->getPropKey();
if (!keyname || strncmp(keyname, "Names", 5))
continue;
files.append(params->queryProp(iter->getPropKey()));
iter->next();
}
}
#endif
if (netAddressStr.length() < 1)
throw MakeStringException(ECLWATCH_INVALID_INPUT, "Network address not specified.");
if (pathStr.length() < 1)
throw MakeStringException(ECLWATCH_INVALID_INPUT, "Path not specified.");
if (nameStr.length() < 1)
throw MakeStringException(ECLWATCH_INVALID_INPUT,"File name not specified.");
char pathSep = '/';
if ((osStr.length() > 1) && (atoi(osStr.str())== OS_WINDOWS))
{
pathSep = '\\';
}
pathStr.replace(pathSep=='\\'?'/':'\\', pathSep);
if (*(pathStr.str() + pathStr.length() -1) != pathSep)
pathStr.append( pathSep );
StringBuffer fullName;
fullName.appendf("%s%s", pathStr.str(), nameStr.str());
StringBuffer headerStr("attachment;");
headerStr.appendf("filename=%s", nameStr.str());
RemoteFilename rfn;
rfn.setRemotePath(fullName.str());
SocketEndpoint ep(netAddressStr.str());
rfn.setIp(ep);
Owned<IFile> rFile = createIFile(rfn);
if (!rFile)
throw MakeStringException(ECLWATCH_CANNOT_OPEN_FILE,"Cannot open file %s.",fullName.str());
OwnedIFileIO rIO = rFile->openShared(IFOread,IFSHfull);
if (!rIO)
throw MakeStringException(ECLWATCH_CANNOT_READ_FILE,"Cannot read file %s.",fullName.str());
IFileIOStream* ioS = createIOStream(rIO);
context.addCustomerHeader("Content-disposition", headerStr.str());
response->setContent(ioS);
response->setContentType(HTTP_TYPE_OCTET_STREAM);
response->send();
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return;
}