title: How to setOwner() of file after uploading it to a folder in Drive?
body: <p><strong>Desired Behaviour</strong></p>
  
  <p>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.  </p>
  
  <p>(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).  </p>
  
  <p><strong>What I've Tried</strong></p>
  
  <p>This answer:</p>
  
  <p><a href="https://stackoverflow.com/a/10821130">https://stackoverflow.com/a/10821130</a></p>
  
  <p>Points to a method called <a href="https://developers.google.com/apps-script/reference/drive/file#setowneremailaddress" rel="nofollow noreferrer">setOwner(emailAddress)</a></p>
  
  <p>So I tried:</p>
  
  <pre><code>// 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");
  </code></pre>
  
  <p><strong>Current Behaviour</strong></p>
  
  <p>The file ownership is not changing.  </p>
  
  <p>Developer Tools > Console error is:</p>
  
  <pre><code>Uncaught ScriptError: Invalid argument: sharing.user
  </code></pre>
  
  <p>With questions about that particular error here:</p>
  
  <p><a href="https://stackoverflow.com/questions/26529514/trying-to-change-owner-on-files-in-google-drive">Trying to change owner on files in Google Drive</a></p>
  
  <p><strong>Other Settings</strong></p>
  
  <p><code>Publish</code> > <code>Deploy as web app</code> > <code>Execute the app as</code> > <code>"User accessing the web app"</code></p>
  
  <p><code>Publish</code> > <code>Deploy as web app</code> > <code>Who has access to the app</code> > <code>"Anyone"</code></p>