繁体   English   中英

带有python的Onedrive API:路径和上传

[英]Onedrive API with python : path and upload

我使用python,我想将文件上传到Onedrive上的特定文件夹中
我在data / project1 / sample.xlsx文件夹中有一个现有的XLSX文件,我想将此文件复制到copy / all_files / sample.xlsx文件夹中(如果文件已经存在,则可以替换)

我执行下面的代码,文件上传到我的根文件夹中)

returned_item = client.item(drive='me', id='root').children['sample.xlsx'].upload('sample.xlsx')

但我不能指定一个特定的文件夹来上传我的文件,能否请您告诉我这怎么可能?

如果我指定这样的路径,那是行不通的

returned_item = client.item(drive='me', id='root').children['copy/all_files/sample.xlsx'].upload('sample.xlsx')

我从这里使用了代码和配置https://developer.microsoft.com/zh-cn/graph/quick-start

你几乎拥有它,你只需要更改idpath在client.item()

因此,假设该文件夹称为all_files ,您可以像这样上传:

returned_item = client.item(drive='me', path='all_files').children['sample.xlsx'].upload('sample.xlsx')

暂无
暂无

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

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