Desired Behaviour
This is my first attempt at a google apps script and I want a user to be able to upload a document to a shared folder (with edit access), but then change the permissions of the file so that the user cannot delete the file and can only view it.
(If this is not specifically possible, I am interested in any method that achieves the same result - ie an admin has edit access to a folder of documents uploaded by users with view only access).
What I've Tried
This answer:
https://stackoverflow.com/a/10821130
Points to a method called setOwner(emailAddress)
So I tried:
// define the target folder to create the file in
var driveFolder = DriveApp.getFoldersByName("My Folder").next();
// create a file in the target folder and set a different owner
var driveFile = driveFolder.createFile(formBlob).setOwner("test@gmail.com");
Current Behaviour
The file ownership is not changing.
Developer Tools > Console error is:
Uncaught ScriptError: Invalid argument: sharing.user
With questions about that particular error here:
Trying to change owner on files in Google Drive
Other Settings
Publish
> Deploy as web app
> Execute the app as
> "User accessing the web app"
Publish
> Deploy as web app
> Who has access to the app
> "Anyone"