-1

I've an app script that create a PDF file, and return the download url to the client, but the file is not downloadable if the user does not have access.

I got this url generated by the code below, how can I make it downloadable regardless for any one click it.

  SpreadsheetApp.flush();  
  var theBlob = destSpreadsheet.getBlob().setName(REPORT);  
  var newFile = folder.createFile(theBlob);
  var link = newFile.getDownloadUrl()
  //Delete the temporary sheet
  DriveApp.getFileById(destSpreadsheet.getId()).setTrashed(true);
  return link;
Rubén
  • 34,714
  • 9
  • 70
  • 166
Hasan A Yousef
  • 22,789
  • 24
  • 132
  • 203
  • Possible duplicate [Google Apps Script to open a URL](https://stackoverflow.com/q/10744760/1595451) – Rubén Feb 21 '21 at 22:18
  • In order to correctly understand about your goal, can you provide your whole script for replicating your current issue? And, can I ask you about the method for executing your script? – Tanaike Feb 22 '21 at 00:16
  • Do you mean that you want to grant everyone permissions in the selected sheet? You want to set the permissions to "available to everyone" with Apps Script? – iansedano Feb 22 '21 at 09:42

1 Answers1

0

You have to create an ui and open a new tab with your url from there. Like this

enter image description here

In main approach you need call

const newWin = window.open(url, "_blank");

after you created the file.

See this snippet for full explanation https://google-apps-script-snippets.contributor.pw/snippets/common_ui/open_url_in_browser/

contributorpw
  • 4,739
  • 5
  • 27
  • 50