久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 Google Drive API 將文件復制到特定的父文件夾

Copy file into a specific parent folder with Google Drive API?(使用 Google Drive API 將文件復制到特定的父文件夾中?)
本文介紹了使用 Google Drive API 將文件復制到特定的父文件夾中?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我使用的是 Python 2.7 和 服務帳號 根據標題將 Google Drive 中的文件復制到另一個文件夾中.這需要我執行五 (5!) 個命令:

I'm using Python 2.7 and a service account to copy a file in Google Drive into another folder based on its title. This requires me to execute five (5!) commands:

  1. 按標題查找文件 ID.(files().list)
  2. 按標題查找父文件夾 ID (files().list)
  3. 復制文件(files().copy)
  4. 將所有權轉讓給真實帳戶(files().insert)
  5. 移入父文件夾.(parents().insert)

這一切都有效,但我想減少調用次數,首先這意味著緩存 ID,這樣我就不必調用 files().list.我要做的下一件事,特別是我遇到這個問題的地方,是如何在 files().copy 命令中設置父文件夾 within.該文檔有一個可選的 parents 參數,描述如下:

This all works but I'd like to reduce the number of calls and first that means caching the ID's so I don't have to call files().list. The next thing I'm trying to do, and specifically where I'm at with this question, is how to set the parent folder within the files().copy command. The documentation has an optional parents parameter described like so:

包含此文件的父文件夾的集合.設置此字段會將文件放入所有提供的文件夾中.插入時,如果沒有提供文件夾,文件將放在默認的根文件夾中.

Collection of parent folders which contain this file. Setting this field will put the file in all of the provided folders. On insert, if no folders are provided, the file will be placed in the default root folder.

雖然它沒有說,但我知道它是指父 ID,因為這是在其他地方使用的.但是,在客戶端庫中設置這個數組并不會產生效果:沒有錯誤并且文件肯定不在正確的文件夾中.

Although it doesn't say, I know it means parent ID's since that's what is used everywhere else. However, setting this array in the client library doesn't produce an effect: no error and the file is definitely not in the right folder.

newfile = {'title': newtitle, 'parents' : [ parentFolderId ]}
service.files().copy(fileId=originalId, body=newfile).execute()

有沒有人有運氣有這個?我還缺少什么嗎?

Has anyone had any luck with this? Is there something else I'm missing?

獎勵:在復制命令中轉移所有權?也許我的服務帳戶可以冒充我?

Bonus: transfer ownership in copy command? Perhaps my service account could impersonate me?

推薦答案

啊哈!parents 數組是具有 id 字段的對象列表:

Ah ha! The parents array is a list of objects with the id field:

newfile = {'title': newtitle, 'parents' : [ { "id" : parentFolderId } ]}
service.files().copy(fileId=originalId, body=newfile).execute()

如果/當我弄清楚如何設置權限時,我會更新這個.

I'll update this if/when I figure out how to set permissions also.

這里有個奇怪的提示是文件仍然被復制到驅動器根目錄以及我指定的父文件夾.

One strange note here is that the file is still being copied to the drive root as well as the parent folder(s) I specify.

這篇關于使用 Google Drive API 將文件復制到特定的父文件夾中?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Troubles while parsing with python very large xml file(使用 python 解析非常大的 xml 文件時出現問題)
Find all nodes by attribute in XML using Python 2(使用 Python 2 在 XML 中按屬性查找所有節點)
Python - How to parse xml response and store a elements value in a variable?(Python - 如何解析 xml 響應并將元素值存儲在變量中?)
How to get XML tag value in Python(如何在 Python 中獲取 XML 標記值)
How to correctly parse utf-8 xml with ElementTree?(如何使用 ElementTree 正確解析 utf-8 xml?)
Parse XML from URL into python object(將 XML 從 URL 解析為 python 對象)
主站蜘蛛池模板: 欧美在线观看一区 | 在线观看www视频 | 亚洲人人 | 日韩视频在线一区 | 99久久亚洲 | 国产一区二区欧美 | 精品国产免费一区二区三区演员表 | 一区二区三区精品在线视频 | 久久久久九九九九 | 国产日韩欧美一区二区在线播放 | 欧美日韩一区在线播放 | 日韩中文一区二区三区 | 国产成人99久久亚洲综合精品 | 色综合欧美 | 91在线观看| 欧美日韩国产在线观看 | 久草.com| 亚洲自拍偷拍视频 | 欧美性生活免费 | 久久久精彩视频 | 欧美成人一区二区 | 最新av在线网址 | 成人福利网站 | 日韩三区 | 天天澡天天操 | 亚洲国产网站 | 在线观看黄色电影 | 午夜免费成人 | 国产精品美女久久久免费 | 欧美乱操 | 九九热精品免费 | 污免费网站 | 欧美又大粗又爽又黄大片视频 | 免费观看日韩精品 | 亚洲精品福利在线 | 日本午夜视频 | 日韩中文字幕2019 | 一区二区三区四区国产 | 91国自产 | 国产黄色大片在线免费观看 | 欧美黄色一区 |