当前位置: 首页>>代码示例>>C++>>正文


C++ QFile::setParent方法代码示例

本文整理汇总了C++中QFile::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ QFile::setParent方法的具体用法?C++ QFile::setParent怎么用?C++ QFile::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QFile的用法示例。


在下文中一共展示了QFile::setParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onButtonSendClicked

void Shoter::onButtonSendClicked()
{
	/*Create file */
	QDate date = QDate::currentDate();
	QString name_file = date.toString();
	QString savedFile = name_file+".png";
	QTemporaryFile file;
	file.setFileName(savedFile);
	if (!m_screenshot.save(&file)) {
		qDebug("file is not saved");
		exit(1);
	}
	// qDebug()<<file.fileName();
	QFile *openFile = new QFile(savedFile);
	openFile->open(QIODevice::ReadOnly);
	QHttpMultiPart *multi = new QHttpMultiPart(QHttpMultiPart::FormDataType);
	/* Upload to ipix.su */
	if (ui->comboBox->currentIndex()== 0) {
		QHttpPart file;
		file.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("image/png"));
		file.setHeader(QNetworkRequest::ContentDispositionHeader,QVariant("form-data; name=\"file\"; filename=\""+savedFile+"\""));
		file.setBodyDevice(openFile);
		openFile->setParent(multi);
		multi->append(file);
		this->upload("http://ipix.su/api/upload",multi);
		/* upload to pix.academ.org */
	} else if (ui->comboBox->currentIndex() == 1) {
		QHttpPart action;
		action.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("name=\"action\""));
		action.setBody("upload_image");
		QHttpPart image;
		image.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png"));
		image.setHeader(QNetworkRequest::ContentDispositionHeader,
						QVariant("form-data; name=\"image\"; filename=\""+savedFile+"\""));
		image.setBodyDevice(openFile);
		openFile->setParent(multi);
		multi->append(action);
		multi->append(image);
		upload("http://pix.academ.org", multi);
		/* Upload to ompldr.org*/
	} else if (ui->comboBox->currentIndex() == 2) {
		QHttpPart file1;
		file1.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png"));
		file1.setHeader(QNetworkRequest::ContentDispositionHeader,
						QVariant("form-data; name=\"file1\"; filename=\""+savedFile+"\""));
		file1.setBodyDevice(openFile);
		openFile->setParent(multi);
		multi->append(file1);
		upload("http://ompldr.org/upload", multi);
	}
}
开发者ID:CyberSys,项目名称:qutim,代码行数:51,代码来源:shoter.cpp

示例2: connectToServer

void IVEFStreamHandler::connectToServer(QString host, int port, QString user, QString password, QString logFileName, bool slipstream, bool statistics) {


    QString portString;
    portString.setNum(port);
    std::cout << QString("iListen opening connection to %1:%2").arg(host, portString).toLatin1().data() << std::endl;

    // should we use keep track of line load
    m_statistics = statistics;

    // should we use compression
    m_slipstream = slipstream;

    // setup the socket
    m_tcpSocket->connectToHost(host, port);

    // store some info for the login
    m_user = user;
    m_password = password;

#ifdef HAVE_ZLIB
    // setup decompression mechanism
    // we cannot use Qt for decompression since we do not know where the chunk starts or ends.
    if ( m_slipstream ) {
        m_strm.zalloc = Z_NULL;
        m_strm.zfree = Z_NULL;
        m_strm.opaque = Z_NULL;
        m_strm.avail_in = 0;
        m_strm.next_in = Z_NULL;
        if (inflateInit(&m_strm) != Z_OK) {
            std::cout << "iListen error initiating zlib stream" << std::endl;
        }
    }
#endif

    // set a timer to check the bytes in/out every minte
    if ( m_statistics ) {
        QTimer *timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(slotStatisticsTimerFired()));
        timer->start(TIMER_INTERVAL*1000);
    }

    // setup the logstream if needed
    if (logFileName != "") {
        QFile* file = new QFile(logFileName);
        file->setParent(this); // make sure it gets cleaned up

        if (!file->open(QIODevice::WriteOnly | QIODevice::Text)) {
            std::cerr << QString("iListen error opening file: %1 for writing").arg(logFileName).toLatin1().data() << std::endl;
            std::exit(1);
        }

        m_log = new QTextStream(file);
        m_log->setCodec("UTF-8");
        *m_log << "<xml>\n"; // create a start tag
        m_log->flush();
    } else {
        m_log = NULL;
    }
}
开发者ID:liyuqing1202,项目名称:ivef-sdk,代码行数:60,代码来源:ivefstreamhandler.cpp

示例3: send

void Syncer::send(QMap<QString, QString>& posts, QStringList& files)
{
    QNetworkRequest request(QUrl(url + posts["command"]));
    QHttpMultiPart* parts = new QHttpMultiPart(QHttpMultiPart::FormDataType);

    QMapIterator<QString, QString> i(posts);
    while (i.hasNext()) {
        i.next();
        QHttpPart* part = new QHttpPart();
        part->setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\""+ i.key() +"\""));
        part->setBody(i.value().toUtf8());
        parts->append(*part);
    }

    foreach (QString filename, files) {
        QFileInfo finfo(filename);
        QFile* file = new QFile(finfo.absoluteFilePath());
        if (file->open(QIODevice::ReadOnly)) {
            QHttpPart* part = new QHttpPart();
            part->setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/"+ finfo.suffix().toLower() +""));
            part->setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; filename=\""+ finfo.fileName() +"\""));
            part->setBodyDevice(file);
            file->setParent(parts); // for delete time
            parts->append(*part);
        }
    }
开发者ID:nournia,项目名称:ketabkhaane,代码行数:26,代码来源:syncer.cpp

示例4: setFile

void MockGeoNetworkReply::setFile(QFile* file)
{
    delete m_file;
    m_file = file;
    if (m_file)
        m_file->setParent(this);
}
开发者ID:kobolabs,项目名称:qtlocation,代码行数:7,代码来源:tst_routing.cpp

示例5: postTaskResults

bool ServerListener::postTaskResults(QString taskId, QString filepath)
{
    QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);

    QHttpPart textPart;
    textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"task_assignment_id\""));
    textPart.setBody(taskId.toUtf8());

    QHttpPart filePart;
    filePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
    filePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("attachment; name=\"result_file\"; filename=\"out.csv\""));
    QFile *file = new QFile(filepath);
    file->open(QIODevice::ReadOnly);
    filePart.setBodyDevice(file);
    file->setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart

    multiPart->append(textPart);
    multiPart->append(filePart);

    QEventLoop loop;
    QNetworkAccessManager* manager = new QNetworkAccessManager();
    QNetworkRequest request = QNetworkRequest(QUrl(ClientSettingsManager::getServerUrl() + "postTaskData"));
    connect(manager, SIGNAL(finished(QNetworkReply*)), &loop, SLOT(quit()));
    manager->post(request, multiPart);
    loop.exec();
    file->close();
    delete multiPart;
    delete manager;
    return true;
}
开发者ID:Vvnrck,项目名称:remote-v8-client,代码行数:30,代码来源:serverlistener.cpp

示例6: uploadImage

void imgUploader::uploadImage(QString FileName, QString PhpUploadURL, QString FieldName)
{

    QUrl serviceUrl = QUrl(PhpUploadURL);

    QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);

    QNetworkRequest request(serviceUrl);
    request.setRawHeader("User-Agent", UserAgent.toAscii());

    QHttpPart imagePart;
    imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
    imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"" + FieldName + "\"; filename=\"" + FileName +  "\""));

    QFile *file = new QFile(FileName);
    file->setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart
    file->open(QIODevice::ReadOnly);

    imagePart.setBodyDevice(file);
    multiPart->append(imagePart);

    // Call the webservice
    //QNetworkAccessManager *networkManager = new QNetworkAccessManager(this);
    currentUpload =  manager.post(request, multiPart);

    connect(currentUpload,SIGNAL(uploadProgress(qint64,qint64)),this, SLOT(onUploadProgress(qint64,qint64)));
    connect(currentUpload, SIGNAL(finished()),this,SLOT(onUploadFinished()));

    Uploading = true;
    //reply->deleteLater();
}
开发者ID:badgeek,项目名称:FotomatisUploader,代码行数:31,代码来源:imguploader.cpp

示例7: uploadHtmlSchedule

QString ccloud::uploadHtmlSchedule(QString htmlpath)
{
    qDebug() << "upload test";
    QFile *file = new QFile( htmlpath );
    QFileInfo info( htmlpath );
    if (!file->exists()){
        qDebug() << "file not exists";
        return "";
    }

    QSettings settings;

    QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
    QHttpPart textPart;
    textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"upload\""));
    textPart.setBody("upload");

    QHttpPart userPart;
    userPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"user_id\""));
    userPart.setBody( settings.value("cloud/id").toString().toLatin1() );

    QHttpPart filePart;
    filePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/html"));
    filePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(
                            QString("form-data; name=\"userfile\"; filename=\"%1\"").arg( info.fileName() )));

    file->open(QIODevice::ReadOnly);
    filePart.setBodyDevice(file);
    file->setParent(multiPart);

    multiPart->append(textPart);
    multiPart->append(userPart);
    multiPart->append(filePart);


    QUrl url("https://api.theocbase.net/theocbase_get.php");
    QNetworkRequest request(url);
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    QNetworkReply *reply = manager->post(request,multiPart);
    multiPart->setParent(reply);

    QEventLoop loop;
    connect(reply,SIGNAL(finished()),&loop,SLOT(quit()));
    loop.exec();
    QString replystr = reply->readAll();

    if (reply->error() == QNetworkReply::NoError) {
        if (replystr == "true"){
            return "https://schedule.theocbase.net/" + info.fileName();
        }else{
            return "";
        }
    } else {
        QMessageBox::information(0,"","Error when uploding html-schedule to cloud\n" + reply->errorString());
        return "";
    }


}
开发者ID:fabianomarechal,项目名称:teocbase,代码行数:59,代码来源:ccloud.cpp

示例8: handleUploadRequestFinished

	void DriveManager::handleUploadRequestFinished ()
	{
		QNetworkReply *reply = qobject_cast<QNetworkReply*> (sender ());
		if (!reply)
			return;

		reply->deleteLater ();
		QString path = Reply2FilePath_.take (reply);

		const int code = reply->
				attribute (QNetworkRequest::HttpStatusCodeAttribute).toInt ();
		if (code != 200)
		{
			qWarning () << Q_FUNC_INFO
					<< "upload initiating failed with code:"
					<< code;
			return;
		}

		emit uploadStatusChanged (tr ("Uploading..."), path);

		QFile *file = new QFile (path);
		if (!file->open (QIODevice::ReadOnly))
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to open file: "
					<< file->errorString ();
			return;
		}

		QUrl url (reply->rawHeader ("Location"));
		QNetworkRequest request (url);
#ifdef HAVE_MAGIC
		request.setHeader (QNetworkRequest::ContentTypeHeader,
				magic_file (Magic_, path.toUtf8 ()));
#endif
		request.setHeader (QNetworkRequest::ContentLengthHeader,
				QString::number (QFileInfo (path).size ()).toUtf8 ());

		QNetworkReply *uploadReply = Core::Instance ().GetProxy ()->
				GetNetworkAccessManager ()->put (request, file);
		file->setParent (uploadReply);
		Reply2FilePath_ [uploadReply] = path;

		connect (uploadReply,
				SIGNAL (finished ()),
				this,
				SLOT (handleUploadFinished ()));
		connect (uploadReply,
				SIGNAL (error (QNetworkReply::NetworkError)),
				this,
				SLOT (handleUploadError (QNetworkReply::NetworkError)));
		connect (uploadReply,
				SIGNAL (uploadProgress (qint64, qint64)),
				this,
				SLOT (handleUploadProgress (qint64, qint64)));
	}
开发者ID:Kalarel,项目名称:leechcraft,代码行数:57,代码来源:drivemanager.cpp

示例9: upload

void LoginManager::upload(const QString &path, int nid, const QString &title, const QString &description, const QString& priv, const QString& license, const QString& tags)
      {
      //qDebug() << "file upload";
      KQOAuthRequest *oauthRequest = new KQOAuthRequest(this);
      QUrl url("https://api.musescore.com/services/rest/score.json");
      if (nid > 0)
            url = QUrl(QString("https://api.musescore.com/services/rest/score/%1/update.json").arg(nid));
      oauthRequest->initRequest(KQOAuthRequest::AuthorizedRequest, url);
      oauthRequest->setConsumerKey(_consumerKey);
      oauthRequest->setConsumerSecretKey(_consumerSecret);
      oauthRequest->setToken(_accessToken);
      oauthRequest->setTokenSecret(_accessTokenSecret);

      oauthRequest->setContentType("multipart/form-data");

      QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);

      QHttpPart filePart;
      filePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/octet-stream"));
      filePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"score_data\"; filename=\"temp.mscz\""));
      QFile *file = new QFile(path);
      file->open(QIODevice::ReadOnly);
      filePart.setBodyDevice(file);
      file->setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart
      multiPart->append(filePart);

      QHttpPart titlePart;
      titlePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"title\""));
      titlePart.setBody(title.toUtf8());
      multiPart->append(titlePart);

      QHttpPart descriptionPart;
      descriptionPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"description\""));
      descriptionPart.setBody(description.toUtf8());
      multiPart->append(descriptionPart);

      QHttpPart privatePart;
      privatePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"private\""));
      privatePart.setBody(priv.toUtf8());
      multiPart->append(privatePart);

      QHttpPart licensePart;
      licensePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"license\""));
      licensePart.setBody(license.toUtf8());
      multiPart->append(licensePart);

      QHttpPart tagsPart;
      tagsPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"tags\""));
      tagsPart.setBody(tags.toUtf8());
      multiPart->append(tagsPart);

      connect(_oauthManager, SIGNAL(requestReady(QByteArray)),
            this, SLOT(onUploadRequestReady(QByteArray)));
      oauthRequest->setHttpMultiPart(multiPart);
      _oauthManager->executeRequest(oauthRequest);
     }
开发者ID:FryderykChopin,项目名称:MuseScore,代码行数:56,代码来源:loginmanager.cpp

示例10: upload

void ImgurUploader::upload(const QString &fileName)
{
    QFile *file = new QFile(fileName);

    if (!file->open(QIODevice::ReadOnly)) {
        emit error(ImageUploader::FileError, tr("Unable to read screenshot file"), fileName);
        file->deleteLater();
        return;
    }

    QNetworkRequest request(QUrl("https://api.imgur.com/3/image"));
    request.setRawHeader("Authorization", QString("Client-ID %1").arg(clientId()).toLatin1());

    QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);

    if (!mSettings.value("anonymous", true).toBool()) {
        request.setRawHeader("Authorization", QByteArray("Bearer ") + mSettings.value("access_token").toByteArray());

        if (!mSettings.value("album").toString().isEmpty()) {
            QHttpPart albumPart;
            albumPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"album\""));
            albumPart.setBody(mSettings.value("album").toByteArray());
            multiPart->append(albumPart);
        }
    }

    QHttpPart imagePart;
    imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QMimeDatabase().mimeTypeForFile(fileName, QMimeDatabase::MatchExtension).name());
    imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"image\""));

    imagePart.setBodyDevice(file);
    file->setParent(multiPart);
    multiPart->append(imagePart);

    QNetworkReply *reply = Uploader::network()->post(request, multiPart);
    reply->setProperty("fileName", fileName);
    this->setProperty("fileName", fileName);
    multiPart->setParent(reply);

#ifdef Q_OS_WIN
    connect(reply, &QNetworkReply::sslErrors, [reply](const QList<QSslError> &errors) {
        Q_UNUSED(errors);
        if (QSysInfo::WindowsVersion <= QSysInfo::WV_2003) {
            reply->ignoreSslErrors();
        }
    });
#endif

    connect(reply, &QNetworkReply::uploadProgress, this, &ImgurUploader::uploadProgress);
    connect(this , &ImgurUploader::cancelRequest, reply, &QNetworkReply::abort);
    connect(this , &ImgurUploader::cancelRequest, reply, &QNetworkReply::deleteLater);

    connect(reply, &QNetworkReply::finished, this, &ImgurUploader::finished);
}
开发者ID:Neyoui,项目名称:Lightscreen,代码行数:54,代码来源:imguruploader.cpp

示例11: addFile

void NetworkComm::addFile(QString key, const QByteArray value, const QByteArray file_extension, const QByteArray file_type){
    QHttpPart* filePart;
    filePart = new QHttpPart();
    filePart->setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\""+key+"\"; filename=\""+"myfile."+file_extension+"\""));
    filePart->setHeader(QNetworkRequest::ContentTypeHeader, QVariant(file_type));
    QFile *file = new QFile(value);
    file->open(QIODevice::ReadOnly);
    filePart->setBodyDevice(file);
    file->setParent(multiPart);
    multiPart->append(*filePart);
}
开发者ID:redrip,项目名称:OP-Sigma-Mobile,代码行数:11,代码来源:networkcomm.cpp

示例12: addImage

void NetworkComm::addImage(QString key, const QByteArray value){
    QHttpPart* imagePart;
    imagePart = new QHttpPart();
    imagePart->setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\""+key+"\"; filename=\"myfile.jpg\""));
    imagePart->setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
    QFile *file = new QFile(value);
    file->open(QIODevice::ReadOnly);
    imagePart->setBodyDevice(file);
    file->setParent(multiPart);
    multiPart->append(*imagePart);
    //params.addQueryItem(key,value);
}
开发者ID:redrip,项目名称:OP-Sigma-Mobile,代码行数:12,代码来源:networkcomm.cpp

示例13: slotNotify

void Toasty::slotNotify(Snore::Notification notification)
{
    QString key = settingsValue(ToastyConstants::DeviceID).toString();
    if (key.isEmpty()) {
        return;
    }
    QNetworkRequest request(QUrl::fromUserInput(QLatin1String("http://api.supertoasty.com/notify/") + key));
    QHttpMultiPart *mp = new QHttpMultiPart(QHttpMultiPart::FormDataType);

    QHttpPart title;
    title.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"title\"")));
    title.setBody(notification.title().toUtf8().constData());
    mp->append(title);

    QHttpPart text;
    text.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"text\"")));
    text.setBody(notification.text().toUtf8().constData());
    mp->append(text);

    QHttpPart app;
    app.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"sender\"")));
    app.setBody(notification.application().name().toUtf8().constData());
    mp->append(app);

    QHttpPart icon;

    icon.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QLatin1String("form-data; name=\"image\"; filename=\"") + notification.icon().localUrl(QSize(128, 128)) + QLatin1Char('"')));
    icon.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QLatin1String("image/png")));
    QFile *file = new QFile(notification.icon().localUrl(QSize(128, 128)));
    file->open(QIODevice::ReadOnly);
    icon.setBodyDevice(file);
    mp->append(icon);

    QNetworkReply *reply =  m_manager.post(request, mp);
    mp->setParent(reply);
    file->setParent(reply);

    connect(reply, &QNetworkReply::finished, [reply]() {
        qCDebug(SNORE) << reply->error();
        qCDebug(SNORE) << reply->readAll();
        reply->close();
        reply->deleteLater();
    });

}
开发者ID:KDE,项目名称:snorenotify,代码行数:45,代码来源:toasty.cpp

示例14: sendJWT

QNetworkReply* MNetworkManager::sendJWT(const QString url, QJsonObject &params, QString method, const QString snapshotUrl, quint32 timestamp) {
    QJsonObject header;
    header["typ"] = "JWT";
    header["alg"] = "sha256";

    QByteArray encode;
    encode.append(QJsonDocument(header).toJson().toBase64(QByteArray::Base64Encoding));
    encode.append(".");
    encode.append(QJsonDocument(params).toJson().toBase64(QByteArray::Base64Encoding));
    QByteArray signature = QMessageAuthenticationCode::hash(encode, QByteArray(SECRET), QCryptographicHash::Sha256).toHex();

    QByteArray jwt;
    jwt.append(encode);
    jwt.append(".");
    jwt.append(signature);

    QString apiUrl = APIHOST;
    apiUrl.append(url);

    QNetworkRequest request;
    request.setUrl(QUrl(apiUrl));
    request.setRawHeader("JWT", jwt);

    QNetworkReply* reply;
    QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);

    QHttpPart imagePart;
    imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png"));
    imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"screenshot_" + QString("%1").arg(timestamp) + "\"; filename=\"screenshot.jpg\""));
    QFile *file = new QFile(snapshotUrl);
    file->open(QIODevice::ReadOnly);
    imagePart.setBodyDevice(file);
    file->setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart
    multiPart->append(imagePart);

    if (method == "post") {
        reply = this->post(request, multiPart);
    } else {
        reply = this->get(request);
    }
    multiPart->setParent(reply);
    reply->setProperty("imagePath", snapshotUrl);
    reply->setProperty("timestamp", timestamp);
    return reply;
}
开发者ID:alexeyhyn,项目名称:laravel,代码行数:45,代码来源:mnetworkmanager.cpp

示例15: addPart

bool FstReader::addPart(const QString &path, const QString& name) {
    QFile* file = new QFile(path);
    if (!file->open(QIODevice::ReadOnly)) {
        qDebug() << "[ERROR] Couldn't open " << file->fileName();
        return false;
    }
    
    QHttpPart part;
    part.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data;"
                   " name=\"" + name.toUtf8() +  "\";"
                   " filename=\"" + QFileInfo(*file).fileName().toUtf8() +  "\"");
    part.setHeader(QNetworkRequest::ContentTypeHeader, "application/octet-stream");
    part.setBodyDevice(file);
    _dataMultiPart->append(part);
    file->setParent(_dataMultiPart);
    
    return true;
}
开发者ID:Chris7,项目名称:hifi,代码行数:18,代码来源:FstReader.cpp


注:本文中的QFile::setParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。