授权后,我调用了 uploadVideo 函数。但是,我采取了 QNetworkReply :: ProtocolInvalidOperationError 。 this->mOauth
是QOAuth2AuthorizationCodeFlow
的实例。我在哪里做错了?预先感谢。
QNetworkReply * Uploader::uploadVideo(){
QNetworkRequest * request = new QNetworkRequest{videoInsertUrl};
request->setRawHeader("Authorization",
QStringLiteral("Bearer %1").arg(mOauth->token()).toLatin1() );
auto multiPart = new QHttpMultiPart{ QHttpMultiPart::MixedType };
auto videoPart = new QHttpPart{};
auto video = new QFile{ mFileName };
if (!video->open(QIODevice::ReadOnly)){
qDebug()<<" cannot to open video file";
return nullptr;
}
videoPart->setHeader(QNetworkRequest::ContentTypeHeader, QVariant("video/*"));
videoPart->setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("Slug"));
videoPart->setBodyDevice(video);
multiPart->append(*videoPart);
return this->mOauth->networkAccessManager()->post(*request,multiPart);
}