Search code examples
file-uploadgoogle-drive-apigoogle-app-makergoogle-drive-shared-drive

Example or template on how to do file upload in Google AppMaker


can anyone share with me the .zip file for Document Approval template because I can't open it since I'm not using GCS but I wanted to go through how they using Drive Picker widget to upload file and so on.

the error that I got

another thing is, where the file will be uploaded to? is it the owner's Drive? is it possible to upload the document to a single folder of a Team Drive instead? Really appreciate it if anyone can share with me some thoughts or any API will do, Thanks!


Solution

  • The only way to upload files that App Maker provides out of the box is Drive Picker widget and by default it uploads files to current user's Drive root folder. Drive Picker's API allows to change default upload folder, however App Maker doesn't expose the setting at this time. But it has onPickerInit event that provides you with pickerBuilder that you can use to customize your the picker:

    // onPickerInit Drive Picker's event handler
    var uploadView = new google.picker.DocsUploadView();
    uploadView.setParent('ID of the folder to upload to');
    
    pickerBuilder.addView(uploadView);
    

    This trick works both for personal and Team Drive folders.

    Note

    It seems that setParent works only in combination with MULTISELECT_ENABLED drive picker feature enabled.