Saturday 15 June 2013

qt - how to get list of all folders with their name on google-drive(solved) -


I am making an application in QT / C ++ and I wanted to upload images in a special folder. All the folders but this does not give me the name of the folder. I wanted to get their name so that users can select a particular folder from the list of folders and I can upload them to that specific folder. My code: In response to this code, I'm kinda, itag, slalink and item array in which each item is foll fields: type = drive # childReference, id, selflink, childlink I want to get the names of all the folders - I have solved it manually. Here's the code to get the list of all folders and subfolders in QT:

  void googled :: tryFolderListing (QNetworkReply * answer) {Am = new QNetworkAccessManager; QByteArray d = Answer-> ReadAll (); QString x = getValue (d, "access_token"); X = "bearer" + x; Query url ("https://www.googleapis.com/drive/v2/files"); Url.addQueryItem (QString ("q"). ToAscii (), QString ("mimeType = 'application / vnd.google-apps.folder'). ToAscii (); QNetworkRequest request; request.setUrl (url); request. SetRawHeader (QString ("content type") toAscii (), QString ("application / json") toAscii () ..); request.setRawHeader (QString ("authorization") toAscii (), x.toAscii ().); QObject :: Connect (am, signal (end (QNetworkReply *), this, SLOT (uploadfinishedSlot (QNetworkReply *)); am- & gt; Received (request);   

}

First of all, if you are interacting with the user, select a specific file or folder from the disk,Use your own picker is very inefficient and slow and with just a few lines of JavaScript code, you can actually do what you do.

Second, you are using children The list that does not provide enough information for files, you should instead use the query with mimeType = 'application / vnd.google-apps.folder' and trashed = false Folder information in Le will be whatever you want.

Thirdly, you forgot to apply the page token. For some users who have lots of files / folders, they can kill the maximum results and the queries may not show all the files / folders. Take a closer look at the code.

No comments:

Post a Comment