Can Google Apps Script read the contents of a public folder? - google-apps-script

If there's a folder on someone's Drive with sharing set so anyone with the link can view it, can a Google Apps Script see its contents? That is:
DocsList.getFolderByID(id).getFiles()
will show me the contents of a folder on my (or the user's) Drive. But is there a similar method for viewing files in a publicly shared folder? Thanks.

If by "public folder" you mean "a folder in another user's Google Drive that has been shared as public", then the answer is yes.
Nothing special - just use the ID of the folder as you would your own. There are some methods that you will not be able to use, for example Document.getOwner() will complain about permissions.

Related

API Changes for Google Drive’s folder structure and sharing models

I used to use below Google Drive API to move my existing file to another drive folder
drive.files().update(fileId=cloudFile['id'],addParents=sharefile,media_body=media).execute()
I just got an email said that the Google Drive folder structure is changed and I'm not allowed to use "addParent" to share filers anymore. I was wondering how can I do this with drive API? I don't want to re-write the entire code, and I'm looking for the simplest way to replace addParents API.
Answer:
Instead of giving a file multiple parents, you can create a shortcut to another Drive file instead (such as a folder).
More Information:
You can use the shortcuts functionality of Google Drive instead of the multiple parents functionality to emulate the kind of behaviour. From the Documentation:
Shortcuts are files that link to other files on Google Drive.
Shortcuts are Drive files with the application/vnd.google-apps.shortcut MIME type, that point to another file or folder on a Google Drive. You can read more about this here.
References:
Create a Shortcut to a Drive File
Find files & folders with Google Drive shortcuts
G Suite and Drive MIME Types

User with edit privileges made files I own not viewable by me

I shared a folder containing files and subfolders with files with multiple users and gave them edit permissions. One users account has modified the viewing ability(?) of every file and subfolder they had access to. From my account when I open the top level folder I see it empty but I know these files are still there because I own the majority of them and my drive storage amount hasn't changed.
The user claims they have no idea how it happened so maybe that it was an app they unknowingly gave drive access to?
Is there any way I can fix this from the Google Drive web interface? I found Google Apps Scripts has access to the Drive API, should I find a script that can mass change the permissions?
Only the owner can delete the file.
The files were removed from the folder but were not deleted.
Therefore, they take up disk space.
To view files outside the folder, follow these steps:
https://drive.google.com/drive/search?q=is:unorganized%20owner:me
Excuse my bad English
Venca

Can anyone with the shared google link add files to that folder, without having a google account

I have a google drive shared folder link, which has the write privileges such as add files or edit them.
My question is can anyone without google account can still add files if he/she has this link.
Because I tried myself and It does not allow, but at the same time why does the privilege say that anyone with this link can add files.
No. Trying to upload to a public folder will require you to sign-in to your Google account. The interface looks something like this:
I have the same question/quandary. Note that Google's support page says that if the folder is shared with "edit" permissions, the non-Google account should be able to add/edit/delete files to the folder.
https://support.google.com/drive/answer/7166529
I have submitted a Google Drive Support Inquiry 9-6348000021871 on this topic. It also points to this thread. Hopefully the fix will be implemented soon.

Google Drive API - Override Owner in Shared Folder

When sharing a folder, is it possible for the owner to override permissions of the files other writers have created under the folder? Hopefully this can be done with a normal Google account, but requiring Google Apps access is also OK (as long as we only need the owner's, not an admin's credentials to do so)
As far as I know, files inside the shared folders inherits the sharing permissions set by the folder owner. Which means that, permissions set by file owners were overridden by the permissions set by the folder owner as demonstrated in this YouTube video - Steegle.com - Google Drive & Docs - Sharing.
However, please note that there are only certain operations which the folder owner can permit and this does not include change of ownership of files as given in Types, roles and values: how the permissions work.
This discussion on Sharing folders vs sharing files - which has priority in Google Docs Help Forum might also help.

Files in public folder on google drive not visible even via WebViewLink

So I've used a little Google Apps script to make a public folder (type: anyone, role: reader) and then I've requested and received the WebViewLink. But when I go to that link, it says there are no files. I've placed (via Google Drive web interface, not via the app script) an index.html file (document) in that folder.
Do I have to MAKE all the files in the folder via the app script?
I seem to have heard on one of the announcements about this that once the folder is created, you can just drop files into it.
Found the answer myself. The documents in the folder must be of the correct type or they just don't show up. E.g. a google docs document called index.html is NOT an html document. You have to create a standard html page locally and then upload it, but never open or edit it with google docs (drive, whatever) in order for it to be seen. I put detailed instructions on a web page hosted by Google Drive here:
https://googledrive.com/host/0B0ap0WDOII5mbjdwajNBMlRoZUU/