Picker API Reference

The following is a list of classes, methods, and enumerated types available in the Google Picker API. All of these elements belong to the namespace google.picker.* There are two types of classes and enumerated types: those which are used to build and configure the Google Picker, and those which are returned by the Google Picker once the user has selected an item.

Configuration Classes and Types

The following classes and enumerated types are used to build and configure the Google Picker.

DocsUploadView

Use DocsUploadView to upload documents to Google Drive.

DocsUploadView()Constructor.
DocsUploadView.setIncludeFolders(boolean)Allows the user to select a folder in Google Drive to upload to.
DocsUploadView.setParent(string)Sets the upload destination to the specified folder. This overrides ".setIncludeFolders" to false.

DocsView

DocsView is a subclass of View that can be used for Google Drive views.

DocsView(ViewId | undefined)Constructor. The ViewId must be one of the Google Drive views. Default is ViewId.DOCS.
DocsView.setEnableDrives(boolean)Shows shared drives and the files they contain. Note: Feature.SUPPORT_DRIVES needs to be enabled when enabling this.
DocsView.setIncludeFolders(boolean)Show folders in the view items. Do not combine with setOwnedByMe. When setIncludeFolders(true) is set, setOwnedByMe is ignored.
DocsView.setSelectFolderEnabled(boolean)Allows the user to select a folder in Google Drive.
DocsView.setMode(DocsViewMode)Selects which mode the view uses to display the documents.
DocsView.setOwnedByMe(boolean | undefined)Filters the documents based on whether they are owned by the user, or shared with the user. Do not combine this setting with setIncludeFolders. When setIncludeFolders(true) is set, setOwnedByMe is ignored.
DocsView.setParent(string)Sets the initial parent folder to display.
DocsView.setStarred(boolean)Filters the documents based on whether they are starred by the user.

DocsViewMode

DocsViewMode is an enumerated type for displaying data within a DocsView. Use these values in calls to DocsView.setMode.

DocsViewMode.GRIDDisplay documents in a thumbnail grid.
DocsViewMode.LISTDisplay documents in a detailed list.

Feature

Feature is an enumerated type, for turning on/off features for various views. Use these values in calls to PickerBuilder.enableFeature and PickerBuilder.disableFeature.

Feature.MINE_ONLYShow only documents owned by the user when showing items from Google Drive.
Feature.MULTISELECT_ENABLEDAllow user to choose more than one item.
Feature.NAV_HIDDENHide the navigation pane. If the navigation pane is hidden, users can only select from the first view chosen.
Feature.SIMPLE_UPLOAD_ENABLEDFor photo uploads, controls whether per-photo selection (as opposed to per-album) selection is enabled.
Feature.SUPPORT_DRIVESWhether shared drive items should be included in results. Before enabling this make sure to refer Google Drive API documentation for enabling shared drives and make any necessary Drive Rest API changes.

Picker

Picker is the top level object representing the UI action with the user. These objects are not created directly, but instead use the PickerBuilder object.

Picker.isVisible()Get a boolean indicating the current Picker visibility.
Picker.setCallback(function(object))Specify the callback method called whenever the user has selected an item (or canceled.)
Picker.setRelayUrl(string)Specify a relay URL to circumvent cross-domain issues.
Picker.setVisible(boolean)Control the visibility of the Picker object.
Picker.dispose()Disposes the Picker object.

PickerBuilder

PickerBuilder is used to create Picker objects. Except where noted otherwise, the return type of methods below are of type PickerBuilder, allowing you to chain one call after another. See the Google Picker example for typical use.

PickerBuilder()Constructor.
PickerBuilder.addView(View | ViewId)Add a View to the navigation pane.
PickerBuilder.addViewGroup(ViewGroup)Add a ViewGroup to the top-level navigation pane.
PickerBuilder.build()Construct the Picker object. The Picker object is returned.
PickerBuilder.disableFeature(Feature)Disable a picker feature.
PickerBuilder.enableFeature(Feature)Enable a picker feature.
PickerBuilder.getRelayUrl()Get the relay URL, used for gadgets.rpc.
PickerBuilder.getTitle()Get the dialog title.
PickerBuilder.hideTitleBar()Disable the title bar from being shown. To re-enable, call setTitle with a non-empty title or undefined.
PickerBuilder.isFeatureEnabled(Feature)Check if a picker Feature is enabled.
PickerBuilder.setAppId(string)Sets the Google Drive App ID needed to allow application to access the user's files via the Google Drive API.
PickerBuilder.setCallback(method)Set the callback method. This method is called when the user selected items or cancels. The callback method receives a single callback object. The structure of the callback object is described in the JSON Guide.
PickerBuilder.setDeveloperKey(string)Sets the Browser API key obtained from Google API Console. See the Developer's Guide for details on how to obtain the Browser API key.
PickerBuilder.setDocument(document)Set the document.
PickerBuilder.setLocale(string)ISO 639 language code. If the language is not supported, en-US is used. This method provides an alternative to setting the locale at google.load() time. See the Developer's Guide for a list of supported locales.
PickerBuilder.setMaxItems(number)Sets the maximum number of items a user can select.
PickerBuilder.setOAuthToken(string)Sets an OAuth token to use for authenticating the current user. Depending on the scope of the token, only certain views display data. Valid scopes are Google Docs, Drive, Photos, YouTube.
PickerBuilder.setOrigin(string)Sets the origin of picker dialog. The origin should be set to the window.location.protocol + '//' + window.location.host of the top-most page, if your application is running in an iframe.
PickerBuilder.setRelayUrl(string)Set the relay URL, used for gadgets.rpc.
PickerBuilder.setSelectableMimeTypes(string)Set the list of selectable MIME types. Use commas to separate MIME types if more than one is required.
PickerBuilder.setSize()Set the preferred dialog size. The dialog is auto-centered. It has a minimum size of (566,350) and a maximum size of (1051,650).
PickerBuilder.setTitle(string)Set the dialog title.
PickerBuilder.toUri()Returns the URI generated by this builder.

ResourceId

ResourceId is a static class used to generate resource IDs suitable for the Google Documents List API.

ResourceId.generate(Document)Map a document object to a resource ID.

View

View is the abstract base class for the various View classes, such as DocsView.

View(ViewId)Constructor.
View.getId()Returns the ViewId for this view.
View.setMimeTypes(string)Sets the MIME types included in the view. Use commas to separate MIME types if more than one is required. If you don't set MIME types, files of all MIME types are displayed in the view.
View.setQuery(string)For views involving searches, prepopulate the search query with these terms.

ViewGroup

ViewGroup is a visual grouping of views. The root item of the ViewGroup itself must be a View.

ViewGroup(View | ViewId)A ViewGroup is a visual grouping of Views in the navigation pane. The root item of the ViewGroup itself must be View.
ViewGroup.addLabel(string)Add a label to this ViewGroup.
ViewGroup.addView(ViewId | View)Add a view to the ViewGroup. The View can be represented by a view-derived object, or simply by ViewId.
ViewGroup.addViewGroup(ViewGroup)Nest a ViewGroup within the current ViewGroup.

ViewId

ViewId is an enumerated type, used for constructing View and ViewGroup objects.

ViewId.DOCSAll Google Drive document types.
ViewId.DOCS_IMAGESGoogle Drive photos.
ViewId.DOCS_IMAGES_AND_VIDEOSGoogle Drive photos and videos.
ViewId.DOCS_VIDEOSGoogle Drive videos.
ViewId.DOCUMENTSGoogle Drive Documents.
ViewId.DRAWINGSGoogle Drive Drawings.
ViewId.FOLDERSGoogle Drive Folders.
ViewId.FORMSGoogle Drive Forms.
ViewId.PDFSPDF files stored in Google Drive.
ViewId.PRESENTATIONSGoogle Drive Presentations.
ViewId.SPREADSHEETSGoogle Drive Spreadsheets.

Callback Types

The following enumerated types are found in callback data returned by the Google Picker API.

Action

Action is an enumerated type representing the action taken by the user to dismiss the dialog. This value is in the Response.ACTION field in the callback data.

Action.CANCELUser canceled the picker dialog.
Action.PICKEDUser has chosen at least one item.

Document

Document is an enumerated type used to convey information about a specific selected item. Only fields which are relevant to the selected item are returned. This value is in the Response.DOCUMENTS field in the callback data.

Document.DESCRIPTIONA user-contributed description of the selected item.
Document.DURATIONThe duration of a selected video.
Document.EMBEDDABLE_URLA URL for this item suitable for embedding in a web page.
Document.ICON_URLA URL to an icon for this item.
Document.IDThe id for the selected item.
Document.IS_NEWReturns true if the selected item was just uploaded.
Document.LAST_EDITED_UTCThe timestamp describing when this item was last edited.
Document.MIME_TYPEThe MIME type of this item.
Document.NAMEThe name of this item.
Document.NUM_CHILDRENThe number of children contained in this item. For example, the number of files in the selected folder.
Document.PARENT_IDThe parent id of this item. For example, the folder containing this file.
Document.SERVICE_IDA ServiceId describing the service this item was selected from.
Document.THUMBNAILSAn array of Thumbnails which describe the attributes of a photo or video. Thumbnails aren't returned if the selected items belong to Google Drive.
Document.TYPEThe Type of the selected item.
Document.URLA URL to this item.

Response

Response is an enumerated type used to convey information about the user's selected items.

Response.ACTIONAn Action type representing the action taken by the user to dismiss the dialog.
Response.DOCUMENTSAn array of Documents selected by the user.
Response.PARENTSThe IDs of the parent folders for the selected items. (For example, IDs of the parent folders whose files were selected.)
Response.VIEWThe View the user selected these items from.

service-id

ServiceId is an enumerated type used to describe the service the item was selected from. This value is in the Document.SERVICE_ID field of the selected Document.

ServiceId.DOCSGoogle Drive.

thumbnail

Thumbnail is an enumerated type used to convey information about a selected photo or video. This value can be found in the Document.THUMBNAILS field of a selected Document.

Thumbnail.HEIGHTThe height of the photo or video in pixels.
Thumbnail.WIDTHThe width of the photo or video in pixels.
Thumbnail.URLA URL to the selected photo or video.

type

Type is an enumerated type used to catorgize the selected item. This value can be found in the Document.TYPE field of a selected Document.

Type.DOCUMENTThe item is a document.
Type.PHOTOThe item is a photo.
Type.VIDEOThe item is a video.