本文整理汇总了C++中FileItem::getFileName方法的典型用法代码示例。如果您正苦于以下问题:C++ FileItem::getFileName方法的具体用法?C++ FileItem::getFileName怎么用?C++ FileItem::getFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileItem
的用法示例。
在下文中一共展示了FileItem::getFileName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: postByUrl
QByteArray WebUtils::postByUrl(const QUrl &url,
const QMap<QString, QString> &sysAndAppParams,
const QMap<QString, FileItem> &tmpFiles)
{
QHttpMultiPart multiParts(QHttpMultiPart::FormDataType);
QMapIterator<QString, QString> appParamIter(sysAndAppParams);
while (appParamIter.hasNext()) {
appParamIter.next();
QHttpPart appParamPart;
appParamPart.setHeader(QNetworkRequest::ContentTypeHeader,
QVariant("text/plain; charset = UTF-8"));
appParamPart.setHeader(QNetworkRequest::ContentDispositionHeader,
QVariant("form-data; name =" + appParamIter.key().toUtf8()));
appParamPart.setBody(appParamIter.value().toUtf8());
multiParts.append(appParamPart);
}
QMapIterator<QString, FileItem> i(tmpFiles);
while (i.hasNext()) {
i.next();
FileItem fileItem = i.value();
QHttpPart filePart;
filePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(fileItem.getMimeType()));
QString disposition = QString("form-data; name = %1; filename = %2")
.arg(i.key()).arg(fileItem.getFileName());
filePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(disposition));
filePart.setBody(fileItem.getContent());
multiParts.append(filePart);
}
QNetworkReply *reply = qnam.post(QNetworkRequest(url), &multiParts);
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (reply->error()) {
qDebug() << reply->errorString();
return reply->errorString().toUtf8();
} else if (!redirectionTarget.isNull()) {
QUrl newUrl = url.resolved(redirectionTarget.toUrl());
reply->deleteLater();
return postByUrl(newUrl, sysAndAppParams, tmpFiles);
}
QByteArray returnStr = reply->readAll();
reply->deleteLater();
return returnStr;
}