I am uploading files to Google Drive using the Drive REST API. I would like to have some default add-ons enabled on those files by default. I was reading about container-bound scripts here.
But it is only possible to add container-bound script after opening the file in Google Docs UI. Is there any way to bind a script to a file while uploading or after uploading programmatically?
You can create the project of container-bound script type in Google Docs using Apps Script API. And when you have some scripts and you want to add the scripts in the project of container-bound script type, please do the following flow.
You can create it using Method: projects.create
.
POST https://script.googleapis.com/v1/projects
{
"title": string, // project name
"parentId": string, // file ID of Google Docs
}
You can import the scripts in the created project using Method: projects.updateContent
.
PUT https://script.googleapis.com/v1/projects/{scriptId}/content
{
"files": [
{
object(File)
}
],
}
https://www.googleapis.com/auth/script.projects
in the scopes.If this was not what you want, I'm sorry.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With