简体   繁体   中英

Get shareable link of Google Drive files in a specific folder

I've been trying to apply the solution described here , adapting from the PyDrive documentation . What I want is to work on files in a specific folder, not get a list of all files in my Drive (which contains thousands). So I've tried:

files = drive.ListFile({'q': "'myfolder' in parents"}).GetList()

where myfolder is the name of the folder I want to get this list from. However, this returns an HTTP 404 error. Replacing myfolder with root works (per Google's example ), but take ages (so my syntax is correct, but I probably misunderstand what parents represents).

Can anyone help?

I actually was nearly there: I needed to pass the folder ID instead of the name in the query:

files = drive.ListFile({'q': "'folder_id' in parents"}).GetList()

From there, I get a collection of dictionaries from which it's easy to get the file name ( title key) and shareable link ( alternateLink ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM