简体   繁体   English

获取特定文件夹中 Google Drive 文件的可共享链接

[英]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 .我一直在尝试应用这里描述的解决方案,改编自PyDrive 文档 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.其中myfolder是我要从中获取此列表的文件夹的名称。 However, this returns an HTTP 404 error.但是,这会返回 HTTP 404 错误。 Replacing myfolder with root works (per Google's example ), but take ages (so my syntax is correct, but I probably misunderstand what parents represents).root替换myfolder可以工作(根据谷歌的例子),但需要很长时间(所以我的语法是正确的,但我可能误解了parents代表的意思)。

Can anyone help?任何人都可以帮忙吗?

I actually was nearly there: I needed to pass the folder ID instead of the name in the query:实际上我就快到了:我需要在查询中传递文件夹 ID 而不是名称:

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 ).从那里,我得到了一个字典集合,从中可以很容易地获取文件名( title键)和可共享链接( alternateLink )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Google App Engine中访问Google云端硬盘文件[共享链接] - Accessing Google Drive Files in Google App Engine [Shareable Link] Google Drive API:获取上传视频的可共享公开链接 - Google drive API: get the shareable publicly link of a video uploaded 使用 Colab notebook 获取我们 google drive 中文件的可共享链接 - Get a shareable link of a file in our google drive using Colab notebook 在不允许用户下载文件的情况下获取 Google Drive 可共享链接 - Get Google drive shareable link without allowing user to download file Google Drive API v3 更改文件权限并获取可公开共享的链接 (Python) - Google Drive API v3 Change File Permissions and Get Publicly Shareable Link (Python) 可供编辑共享Google云端硬盘API - Shareable By Editors Google Drive API 使用 python 在谷歌驱动器文件夹中读取所有文件的名称(或获取它的链接) - To read the names of all files(or to get the link for it ) inside a google drive folder using python Python:如何使用 folderId 将文件上传到 Google Drive 中的特定文件夹 - Python: How to upload files to a specific folder in Google Drive using folderId 使用python将文件上传到特定的Google Drive文件夹 - Upload files to a specific Google Drive folder using python 有没有办法获取 Google Drive 中文件的文件共享链接? - Is there a way to get the File Sharing Link of files in Google Drive?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM