5

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);
        }
Kara
  • 6,115
  • 16
  • 50
  • 57
user1501783
  • 533
  • 2
  • 9
  • 20
  • I guess the parent only works for browsing, not uploads and that would appear to be a bug. – Ali Afshar Jul 30 '12 at 14:03
  • Ali, you may be interested in the following work-around I found elsewhere for another problem that also fixes my problem. This may have even been suggested by you, but I cannot find the original post. http://stackoverflow.com/a/11680890/1501783 – user1501783 Jul 31 '12 at 00:23

2 Answers2

4

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);
    }
damko
  • 301
  • 1
  • 12
1

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.

James Krimm
  • 149
  • 2
  • 10