QNetworkReply :: ProtocolInvalidOperationError将视频上传到youtube时

时间:2019-03-21 20:36:36

标签: c++ qt youtube-data-api google-oauth2 qnetworkrequest

授权后,我调用了 uploadVideo 函数。但是,我采取了 QNetworkReply :: ProtocolInvalidOperationError this->mOauthQOAuth2AuthorizationCodeFlow的实例。我在哪里做错了?预先感谢。

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);
}

0 个答案:

没有答案