0
votes

I am working on google sites and i want to allow users to upload files to my google drive using google picker API .

Below is my code :

var picker = new google.picker.PickerBuilder()
    .enableFeature(google.picker.Feature.NAV_HIDDEN)
    .enableFeature(google.picker.Feature.MULTISELECT_ENABLED)

    .addView(new google.picker.DocsUploadView().setIncludeFolders(true))
    .setOAuthToken(token)
        .setDeveloperKey(DEVELOPER_KEY)
        .setCallback(pickerCallback)
         .setOrigin('https://script.google.com')

        .setSize(DIALOG_DIMENSIONS.width - 2,
            DIALOG_DIMENSIONS.height - 2)
        .build();
    picker.setVisible(true);

I could able to upload file using this code .But i want to restrict users to upload files to specific folders based on their roles/account(using their mail id).

i tried by share option for folders(OFF -Only specific people can access) in google drive.But it doesn't seems to work for Google Picker API.

If any one have any idea..please help..

1
Do you published your script as a web app? Which settings did you use?Rubén

1 Answers

0
votes

A couple of options to consider

Try approaching this using shared folders. So for each user (eg. user-A) you create a folder (eg called folder-A), and then share folder-A to user-A. You'll need to be aware that that the file would still be owned by User-A, so you would need to add a change ownership step.

Alternatively, don't use the Google picker. It's not too difficult to write your own that has whatever custom functionality you need.