Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select Folder with google Picker

I'm using google the plugin Picker for Google Drive. My idea is select only the folders and get its ID.

Currently not let me select them,now only enter into that directory. I am using this code:

    function MenuCtrl($scope, $location, appId) {
    var onFilePicked = function (data) {
        $scope.$apply(function () {
            if (data.action == 'picked') {
                var id = data.docs[0].id;
                $location.path('/edit/' + id);
            }
        });
    };
    $scope.open = function () {
        var view = new google.picker.View(google.picker.ViewId.FOLDERS);
        view.setMimeTypes('application/vnd.google-apps.folder');

        var picker = new google.picker.PickerBuilder()
            .setAppId(appId)
            .addView(view)
            .setCallback(angular.bind(this, onFilePicked))
            .build();
        picker.setVisible(true);


    };
    $scope.create = function () {
        this.editor.create();
    };
    $scope.save = function () {
        this.editor.save(true);
    }
}

How could I get selected folder without going inside it?

Thank you very much in advance and greetings.

like image 326
user2606850 Avatar asked Jan 16 '14 22:01

user2606850


People also ask

What is the Google file picker API?

The Google File Picker API lets users easily upload files to Google Drive and also select existing files and folders from Drive. The File Upload Forms for Google Drive is written in Google Apps Script and it lets users upload files to the form owner’s folder through the File Picker API.

How can I let a user pick a file from Google Drive?

If your app needs to let a user pick a file from his Google Drive, you might consider using the Google Picker API.

How do I access files and folders using a picker?

Access files and folders by letting the user interact with a picker. You can use the FileOpenPicker and FileSavePicker classes to access files, and the FolderPicker to access a folder. For a complete sample, see the File picker sample.

What is a file picker in an email app?

An email app might display a file picker for the user to pick attachments. With a picker your app can access, browse, and save files and folders on the user's system. Your app receives those picks as StorageFile and StorageFolder objects, which you can then operate on.


1 Answers

I solved the problem, this is the new Code:

$scope.open = function () {

        var docsView = new google.picker.DocsView()
          .setIncludeFolders(true) 
          .setMimeTypes('application/vnd.google-apps.folder')
          .setSelectFolderEnabled(true);


        var picker = new google.picker.PickerBuilder()
          .addView(docsView)
          .setCallback(callback)
          .build();

        picker.setVisible(true);
});

Thanks for the help and greetings!

like image 147
user2606850 Avatar answered Sep 30 '22 13:09

user2606850