0

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"

Community
  • 1
  • 1
user1063287
  • 10,265
  • 25
  • 122
  • 218
  • Is the file created a PDF? Because I am not even able to transfer the ownership for a PDF file through the UI, let alone google apps script. – Adelin Sep 10 '16 at 16:01
  • Possible duplicate of [Transfer ownership of a file to another user in Google Apps Script](https://stackoverflow.com/questions/10796464/transfer-ownership-of-a-file-to-another-user-in-google-apps-script) – Rubén Jun 01 '18 at 02:45

2 Answers2

0

According to Change your sharing settings - Google Drive Help the ownership of uploaded files can't be transferred. For an alternative approach see Google Forms file upload complete example

Community
  • 1
  • 1
Rubén
  • 34,714
  • 9
  • 70
  • 166
0

You have to create a google site and use the upload feature then you can change settings.

Since the file one person directly in google is "not yours" you cannot change it. but if you receive it through a site page you will be the owner.