gapi.client.drive.files.create() can create an empty file on Google Drive. But it cannot directly upload files including contents. I think that this might not be able to upload files and metadata with the multipart/related, although this might be resolved by the future update. So now, as one of workarounds, I use using XMLHttpRequest.
- This sample uses gapi.
- Before you use this, please enable Drive API at API console and carry out the installation of gapi.
- When this script is run, a text file including "sample text" is created to Google Drive.
- When you use this script, please set fileContent and metadata.
In this sample script, a text file including contents is created under a folder.