3

授权后,我调用了uploadVideo函数。但是我已经采取了QNetworkReply::ProtocolInvalidOperationErrorthis->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);
}
4

0 回答 0