Reputation: 145
i want to get which file sharing permission has been set to file with download links. i could not find any parameter for that. here is the code i have which can generate the file download link only.
function listFolderContents() {
var foldername = 'Foldername';
var folderlisting = 'listing of folder ' + foldername;
var folders = DriveApp.getFoldersByName(foldername)
var folder = folders.next();
var contents = folder.getFiles();
var ss = SpreadsheetApp.create(folderlisting);
var sheet = ss.getActiveSheet();
var file;
var name;
var link;
var row;
while(contents.hasNext()) {
file = contents.next();
name = file.getName() + "/" + file.getUrl() + "/" + file.getName();
link = file.getUrl() + "/" + file.getName();
sheet.appendRow( [name] );
}
};
Upvotes: 0
Views: 1413
Reputation: 201378
If my understanding is correct, how about this answer? You can retrieve the sharing permission and the sharing access by the methods of getSharingAccess()
and getSharingPermission()
. When these are used for your script, how about the following modification?
In this modification, the while loop is modified.
while(contents.hasNext()) {
file = contents.next();
name = file.getName() + "/" + file.getUrl() + "/" + file.getName();
link = file.getUrl() + "/" + file.getName();
var sharingPermission = file.getSharingPermission(); // Added
var sharingAccess = file.getSharingAccess(); // Added
sheet.appendRow( [name] );
}
Also if you want to retrieve the editors and viewers, how about adding the following script in the while loop?
var editors = file.getEditors().map(function(e) {return e.getEmail()});
var viewers = file.getViewers().map(function(e) {return e.getEmail()});
If I misunderstood your question and this was not the result you want, I apologize.
Upvotes: 4