【问题标题】:Create a folder google drive in specific path在特定路径中创建文件夹 google drive
【发布时间】:2021-07-06 19:20:02
【问题描述】:

我使用了从这个链接创建文件夹的脚本:Create a folder 它的工作。

file_metadata = {
    'name': 'Invoices',
    'mimeType': 'application/vnd.google-apps.folder'
}
file = drive_service.files().create(body=file_metadata,
                                    fields='id').execute()
print 'Folder ID: %s' % file.get('id')

如何在特定路径中创建文件夹?

【问题讨论】:

  • 欢迎加入堆栈,请阅读How to Ask。我已经编辑了您的问题,以向您展示将来应该如何表达您的问题。尽量记住添加您当前使用的代码,并描述您当前解决方案的问题。

标签: python python-3.x google-api google-drive-api google-api-python-client


【解决方案1】:

您需要将要在其中创建新文件夹的文件夹的 fileId 添加为元数据中的父参数。

file_metadata = {
    'name': 'Invoices',
    'mimeType': 'application/vnd.google-apps.folder'
    'parents': 'FOLDERID'
}
file = drive_service.files().create(body=file_metadata,
                                    fields='id').execute()
print 'Folder ID: %s' % file.get('id')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-22
    • 1970-01-01
    相关资源
    最近更新 更多