We have a working google file picker but our users gets confused by having to select the folders and not being able to save in the root of the current folder they are at. Is there some option that can be used to change the behaviour of the picker so that is possible? Or maybe a different approach entirely?
This is a small snippet of the angular code that sets up the behaviour of the google picker:
const pickerBuilder = new google.picker.PickerBuilder();
view = new google.picker.DocsView()
.setParent('root')
.setIncludeFolders(true);
view.setMimeTypes('application/vnd.google-apps.folder')
.setSelectFolderEnabled(true);
picker = pickerBuilder
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.setOAuthToken(this.oauthToken.access_token)
.addView(view)
.addView(new google.picker.DocsUploadView());
How about creating a picker for selecting the folder, and when the file is selected, create a new instance of the picker with the DocsUploadView and set the parent via DocsUploadView.setParent(string) to the one the user chose.
Just a sketch on how this may be accomplished:
function createPickerFolders() {
const view = new google.picker.DocsView()
.setIncludeFolders(true)
.setSelectFolderEnabled(true)
.setMimeTypes("application/vnd.google-apps.folder");
const picker = new google.picker.PickerBuilder()
.addView(view)
.setAppId(appId)
.setOAuthToken(oauthToken)
.setCallback(pickerViewCallback)
.build();
picker.setVisible(true);
}
function createPickerUpload(folderId) {
const view = new google.picker.DocsUploadView().setParent(folderId);
const picker = new google.picker.PickerBuilder()
.addView(view)
.setAppId(appId)
.setOAuthToken(oauthToken)
.setCallback(pickerUploadCallback)
.build();
picker.setVisible(true);
}
DocsView we create one that renders the DocsUploadView and sets it's parent to the folder selectedfunction pickerViewCallback(data) {
if (data.action == google.picker.Action.PICKED) {
const folderId = data.docs[0].id;
createPickerUpload(folderId);
}
}
In this way we achieve that the folder selected by the user, is the one to which the file is uploaded.
Basically we ended up giving our users 2 options:
not an optimal solution but it made it possible to save in the root AND by having the save text mention folder it would give the user a hint about how the regular save feature works.