Ariel
Ariel

Reputation: 23

Google Picker not showing files

This is my code:

var docParent = "XXXXXXXXXXXXXXXXXXX";
var docsView = new google.picker.DocsView(google.picker.ViewId.FOLDERS);
        docsView.setParent(docParent);
var picker = new google.picker.PickerBuilder().
            addView(docsView).
            setOAuthToken(oauthToken).
            setDeveloperKey(developerKey).
            setCallback(pickerCallback).
            //setOrigin('http://localhost:61003').
            build();
        picker.setVisible(true);

I'd like to set a default folder that might have "sub-folders" and then pick a file inside of them. It was working fine but since a few months it just displays the folders but not the files inside them. So, I've tried to change the addView for a addViewGroup and add FOLDERS and DOCS but it doesn't work either. The folders works always fine, but when i select the sub-folder it says "No items on this folder".

Could you help me please?

Thanks !

Upvotes: 2

Views: 2378

Answers (2)

Dinesh Sharma
Dinesh Sharma

Reputation: 658

i was able to get Folders and files in one view.Add this view

addView(new google.picker.DocsView().setParent('root').setIncludeFolders(true))

Upvotes: 4

ReyAnthonyRenacia
ReyAnthonyRenacia

Reputation: 17613

You are getting the "no items in this folder" because you indicated a strictly FOLDER view by using

var docsView = new google.picker.DocsView(google.picker.ViewId.FOLDERS);

Now I'm not sure if Picker API supports the 'view files inside folder' functionality as I haven't found a way to do it. But, using

 var view = new google.picker.View(google.picker.ViewId.DOCS);

enables you to view all files in your Drive including those that are inside sub-folders.

 function createPicker() {
        var view = new google.picker.View(google.picker.ViewId.DOCS);
        var picker = new google.picker.PickerBuilder().
            addView(view).
            setAppId(appId).
            setOAuthToken(oauthToken).
            setCallback(pickerCallback).
            build();
        picker.setVisible(true);
    }

Upvotes: 0

Related Questions