saurabhpatel7717

Untitled

Jun 21st, 2013
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. void googled::newuploadSettings(QNetworkReply *reply){
  2. QByteArray m_boundary;
  3. m_boundary = "--";
  4. m_boundary += QString("42");
  5.  
  6. QByteArray data = reply->readAll();
  7. qDebug() << data;
  8. QString x = getValue(data,"access_token");
  9. qDebug() << x;
  10. x = "Bearer " + x;
  11. qDebug() << x;
  12. QNetworkRequest request;
  13.  
  14. QUrl url("https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart");
  15. request.setUrl(url);
  16. request.setRawHeader("Content-Length","200000000");
  17. QString y = "multipart/related; boundary=\"" + QString("42") +"\"";
  18. qDebug() << y;
  19. request.setRawHeader("Content-Type",y.toAscii());
  20. request.setRawHeader("Authorization",x.toLatin1());
  21.  
  22. QString str;
  23. str += m_boundary;
  24. str += "\r\n";
  25. str += "Content-Type: ";
  26. str += QString("application/json; charset=UTF-8");
  27. str += "\r\n";
  28. str += QString("{");
  29. str += "\r\n\t";
  30. str += QString("\"title\": \"SMP\"");
  31. str += "\r\n";
  32. str += QString("}");
  33.  
  34. str += "\r\n\r\n";
  35.  
  36.  
  37. str += m_boundary;
  38.  
  39. str += "Content-Type: ";
  40. str += "image/jpeg";
  41.  
  42.  
  43. QByteArray arr;
  44. arr.append(str.toUtf8());
  45. QFile file("/home/saurabh/Pictures/005.jpg");
  46. file.open(QIODevice::ReadOnly);
  47.  
  48.  
  49. arr.append(file.readAll().toBase64());
  50. m_boundary += QString("--");
  51. arr.append(m_boundary);
  52. file.close();
  53. qDebug() << "file";
  54. //qDebug() << str;
  55. //qDebug() << arr;
  56. m_netM = new QNetworkAccessManager;
  57. QObject::connect(m_netM, SIGNAL(finished(QNetworkReply *)),
  58. this, SLOT(uploadfinishedSlot(QNetworkReply *)));
  59.  
  60. m_netM->post(request,arr);
  61.  
  62. }
Add Comment
Please, Sign In to add comment