Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google picker upload

I am trying to make a picker of Google drive that let me to upload new local files to Google Drive. The picker is working and it is showing me my Google Drive files, but there's only the select button and there's not a "upload" button. I added the view google.picker.DocsUploadView() but still not a button.

There it is my createPicker function:

function createPicker() {
  if (pickerApiLoaded && oauthToken) {
    var view = new google.picker.View(google.picker.ViewId.DOCS);
    view.setMimeTypes("image/png,image/jpeg,image/jpg");
    var picker = new google.picker.PickerBuilder()
        .enableFeature(google.picker.Feature.NAV_HIDDEN)
        .enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
        .setAppId(appId)
        .setOAuthToken(oauthToken)
        .addView(view)
        .addView(new google.picker.DocsUploadView())
        .setDeveloperKey(developerKey)
        .setCallback(pickerCallback)
        .build();
     picker.setVisible(true);
  }
}  

Any thoughts?

like image 646
waytosay Avatar asked Oct 27 '25 07:10

waytosay


2 Answers

You'll be using DocsUploadView.

Use this in your createPicker code:

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();

    var picker = new google.picker.PickerBuilder().
        addView(view).
        addView(uploadView).
        setAppId(appId).
        setOAuthToken(oauthToken).
        setCallback(pickerCallback).
        build();
    picker.setVisible(true);
}

 // A simple callback implementation.
function pickerCallback(data) {
    if (data.action == google.picker.Action.PICKED) {
        var fileId = data.docs[0].id;
        alert('The user selected: ' + fileId);
        createPicker();
    }
}

It will look like this. enter image description here

like image 56
ReyAnthonyRenacia Avatar answered Oct 29 '25 20:10

ReyAnthonyRenacia


In the docs example, this line:

.enableFeature(google.picker.Feature.NAV_HIDDEN)

hide the 'upload' tab

like image 44
José Avatar answered Oct 29 '25 20:10

José



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!