Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Google Picker to upload files to Google Drive and place in specific folder

I am attempting to use Google Picker to upload files to a specific folder in Google Drive. Everything works fine when I am just uploading to the root folder, but even after specifying the parent folder as shown in my code below, the files still go to the root folder, not the folder I am specifying. I am certain the folderID is correct, as I am using the same ID elsewhere to create textiles in my GAE app, and place them in subfolders. My code is below:

    function createPicker() {
            // Create a view to search images.
            var view = new google.picker.View(google.picker.ViewId.DOCS);
            view.setMimeTypes('image/png,image/jpeg');

            // Use DocsUploadView to upload documents to Google Drive.
            var uploadView = new google.picker.DocsUploadView().setParent('THE Parent folder ID');

            var picker = new google.picker.PickerBuilder().
                addView(view).
                addView(uploadView).
                setAppId("pressomatic").
                setCallback(pickerCallback).
                build();
            picker.setVisible(true);
        }
like image 817
user1501783 Avatar asked Jul 27 '12 01:07

user1501783


People also ask

What is Google Drive picker?

The Google Picker is a "File Open" dialog for information stored on Google servers. You can use the Google Picker API to allow users to open or upload Google Drive files. Note: To allow users to open Drive files from a mobile app, refer to Google Workspace APIs for Android or Google Workspace APIs for iOS.


2 Answers

You have to add:

enableFeature(google.picker.Feature.MULTISELECT_ENABLED)

In your case it becomes:

    var picker = new google.picker.PickerBuilder().
            enableFeature(google.picker.Feature.MULTISELECT_ENABLED).
            addView(view).
            addView(uploadView).
            setAppId("pressomatic").
            setCallback(pickerCallback).
            build();
        picker.setVisible(true);
    }
like image 50
damko Avatar answered Sep 28 '22 06:09

damko


This is a bug documented in the Picker API Forum: https://groups.google.com/forum/#!topic/Google-Picker-API/xaHcET7JYLw

You have to add:

.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)

In your case it becomes:

var picker = new google.picker.PickerBuilder()
        .enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
        .addView(view)
        .addView(uploadView)
        .setAppId("pressomatic")
        .setCallback(pickerCallback)
        .build();

Hope this helps.

like image 36
James Krimm Avatar answered Sep 28 '22 04:09

James Krimm