/*! * Process server reply data */ void Uploader_MediaCrush::replyFinished(QNetworkReply* reply) { if (reply->error() == QNetworkReply::NoError) { QByteArray response = reply->readAll(); if (response.split(':').count() >= 2) { response = response.split(':').at(1); response = response.mid(2, 12); } _uploadedStrings[UL_DIRECT_LINK].first = "https://" + _host + "/" + response + "." + _currentFormat; _uploadedStrings[UL_DELETE_URL].first = "https://" + _host + "/" + response + "/delete"; Q_EMIT uploadDone(_uploadedStrings[UL_DIRECT_LINK].first); Q_EMIT uploadDone(); } else { Q_EMIT uploadFail(reply->errorString().toAscii()); } reply->deleteLater(); }
void TestRenderServer::uploadFile(QString resPath, QByteArray data){ if(link == NULL){ link = new SheerCloudLink("http://172.245.20.58:8080", "abc", "123"); connect(link, SIGNAL(done()), this, SLOT(uploadDone())); } link->Upload(resPath, data); myHash.remove(fileList[0]); fileList = myHash.keys(); }
void TrollingModel::initialize() { m_DBLayer = new DBLayer(m_filePath+"/database"); connect(m_DBLayer, SIGNAL(storeSignal(int, QString)), &m_journal, SLOT(addJournal(int, QString))); connect(&m_synchronizer, SIGNAL(uploadDone()), this, SLOT(resetJournal())); qDebug() << "start loading"; m_DBLayer->loadObjects(Lure().getType(), &m_factory); m_DBLayer->loadObjects(Trip().getType(), &m_factory); m_DBLayer->loadObjects(Place().getType(), &m_factory); qDebug() << "finished loading"; }
void SlideShare::upload() { qDebug() << ">>>>>>>>> SlideShare::upload()"; QDateTime *time = new QDateTime(); QString ts; ts.setNum(time->toTime_t()); QByteArray data = this->secretKey->toAscii(); data += ts; QFile *file = new QFile(*this->sourceFilename, this); file->open(QFile::ReadOnly); QByteArray fileData ; fileData = file->readAll(); QByteArray postData; postData.append("--BOUNDARY\r\n"); postData.append("Content-Disposition: form-data; name=\"slideshow_srcfile\"; filename=\""); postData.append(file->fileName().toUtf8()); postData.append("\"\r\n"); postData.append("Content-Type: " + MimeTypes::getMimeType(doc->format)); postData.append("\r\n\r\n"); postData.append(fileData); postData.append("\r\n--BOUNDARY\r\n"); QList<QPair<QString, QString> > params; params.append(qMakePair(QString("api_key"), *this->apiKey)); params.append(qMakePair(QString("ts"), ts)); params.append(qMakePair(QString("hash"), QString(QCryptographicHash::hash(data, QCryptographicHash::Sha1).toHex()))); params.append(qMakePair(QString("username"), *this->username)); params.append(qMakePair(QString("password"), *this->password)); params.append(qMakePair(QString("slideshow_title"), doc->title)); if(doc->description != "") params.append(qMakePair(QString("slideshow_description"), doc->description)); if(doc->tags != "") params.append(qMakePair(QString("slideshow_tags"), doc->tags)); QUrl url("http://www.slideshare.net/api/2/upload_slideshow", QUrl::TolerantMode); url.setQueryItems(params); QNetworkRequest request; request.setUrl(url); request.setHeader(QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=BOUNDARY"); request.setHeader(QNetworkRequest::ContentLengthHeader, postData.length()); QNetworkReply *reply = manager.post(request, postData); connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, SIGNAL(uploadProgress(qint64, qint64))); connect(reply, SIGNAL(finished()), this, SIGNAL(uploadDone())); }
/** * Manage replies after the image is uploaded * * @access private */ void ImageShackUploader::imageUploaded() { QHash<QString, QString> usableResponse; ImageShackError::UploadError error; if(uploadsProcessing) { usableResponse = ImageShackResponse::makeResponseUsable(this->networkReply); //qDebug() << usableResponse; if(usableResponse.contains(QString("error"))) { //qDebug() << "* Error in response"; //this->uploadsProcessing = false; if(uploadAborted==false) { error = ImageShackError::getErrorCode(usableResponse); if(error != ImageShackError::NoError) { emit uploadError(error); } this->abortUploads(); } } else { //qDebug() << "* Image uploadé avec succès : \n " << usableResponse; if(uploadAborted==false) { emit uploadDone(new ImageShackResponse(this->fileBeingUploaded,usableResponse)); this->nbFilesUploaded ++; } //qDebug() << "* Nombre de fichiers restant " << filesToUpload.size(); if(nbFilesUploaded == nbFilesToUploads && uploadAborted == false) { this->uploadsProcessing = false; timeoutTimer->stop(); emit endOfUploads(); } } } }
ScreenshotManager::ScreenshotManager(QObject *parent = 0) : QObject(parent) { if (QFile::exists(qApp->applicationDirPath() + QDir::separator() + "config.ini")) { mSettings = new QSettings(qApp->applicationDirPath() + QDir::separator() + "config.ini", QSettings::IniFormat); mPortableMode = true; mHistoryPath = qApp->applicationDirPath() + QDir::separator(); } else { mSettings = new QSettings(); mPortableMode = false; mHistoryPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator(); } initHistory(); connect(Uploader::instance(), SIGNAL(done(QString, QString, QString)), this, SLOT(uploadDone(QString, QString, QString))); }
void TestFolderServer::uploadFile(){ if(link == NULL){ link = new SheerCloudLink("http://172.245.20.58:8080", ui->userLineEdit->text(), ui->lineEdit->text()); } QFile *file = new QFile(ui->fileLineEdit->text()); if(file->open(QIODevice::ReadOnly)){ QString myFilename = file->fileName().section('/', -1); qDebug() << myFilename << "File is ok"; QByteArray massive = file->readAll(); link->Upload(myFilename, massive); //loop.exec(); link->connect( link, SIGNAL(done()), this, SLOT(uploadDone())); ui->uploadPushButton->setEnabled(false); }else{ QMessageBox msgBox; msgBox.setText("The document is not sent."); msgBox.exec(); } }
void Uploader::requestFinished(QNetworkReply * reply) { // Did we have a network error? if (reply->error() != QNetworkReply::NoError) { emit uploadError(tr("Network error: %1").arg(reply->error())); reply->deleteLater(); return; } // Parse the reply QHash<int, QString> linksMap; QDomDocument doc; QString error; if (!doc.setContent(reply->readAll(), false, &error)) { emit uploadError(tr("Parse error: %1").arg(error)); reply->deleteLater(); return; } // See if we have an upload reply, or an error QDomElement rootElem = doc.documentElement(); error = ""; if (rootElem.tagName() == "upload") { // Skip all elements until we reach the <links> tag QDomNode n = rootElem.firstChild(); while (!n.isNull()) { if (n.isElement() && n.toElement().tagName() == "links") { QDomNode innerNode = n.firstChild(); while (!innerNode.isNull()) { if (innerNode.isElement()) { QDomElement e = innerNode.toElement(); if (e.tagName() == "original") { linksMap.insert(OriginalImage, e.text()); } else if (e.tagName() == "small_square") { linksMap.insert(SmallSquare, e.text()); } else if (e.tagName() == "large_thumbnail") { linksMap.insert(LargeThumbnail, e.text()); } else if (e.tagName() == "imgur_page") { linksMap.insert(ImgurPage, e.text()); } else if (e.tagName() == "delete_page") { linksMap.insert(DeletePage, e.text()); } } innerNode = innerNode.nextSibling(); } } n = n.nextSibling(); } } else if (rootElem.tagName() == "error") { // Skip all elements until we reach the <message> tag QDomNode n = rootElem.firstChild(); while (!n.isNull()) { if (n.isElement() && n.toElement().tagName() == "message") { error = n.toElement().text(); } n = n.nextSibling(); } } else { error = tr("Reccived unexpected reply from web service"); } if (!error.isEmpty()) { emit uploadError(error); } else { emit uploadDone(linksMap); } reply->deleteLater(); }