Я использую python и Onedrive, и я хочу скопировать один из моих файлов onedrive в определенный каталог.
На Onedrive у меня есть следующие каталоги и файлы в моем корневом пространстве
1- /test/cdm
--> drive-api.py
2- /test/cdm/data
--> tue.xlsx
3- /all-data
Я хочу скопировать вт.xlsx из / тест / cdm / данные в /все данные
Я использую этот код в drive-api.py
import onedrivesdk
from onedrivesdk.helpers import GetAuthCodeServer
from onedrivesdk.helpers.resource_discovery import ResourceDiscoveryRequest
redirect_uri = 'http://localhost:5000/login/authorized'
client_id = 'xxxxxxxxx'
client_secret = 'yyyyyyyyy'
discovery_uri = 'https://api.office.com/discovery/'
auth_server_url='https://login.microsoftonline.com/common/oauth2/authorize'
auth_token_url='https://login.microsoftonline.com/common/oauth2/token'
http = onedrivesdk.HttpProvider()
auth = onedrivesdk.AuthProvider(http,
client_id,
auth_server_url=auth_server_url,
auth_token_url=auth_token_url)
auth_url = auth.get_auth_url(redirect_uri)
code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)
auth.authenticate(code, redirect_uri, client_secret, resource=discovery_uri)
# If you have access to more than one service, you'll need to decide
# which ServiceInfo to use instead of just using the first one, as below.
service_info = ResourceDiscoveryRequest().get_service_info(auth.access_token)[0]
auth.redeem_refresh_token(service_info.service_resource_id)
client = onedrivesdk.OneDriveClient(service_info.service_resource_id + '/_api/v2.0/', auth, http)
Этот код работает нормально, но это не тот каталог
returned_item = client.item(drive='me', id='root').children['tue-copie.xlsx'].upload('data/tue.xlsx')
Вопрос : Как я могу указать каталог / all-data?
Спасибо за любую помощь заранее






У вас почти получилось, вам просто нужно сменить id на path в client.item ()
Предполагая, что папка называется all-data, вы можете загрузить ее следующим образом:
returned_item = client.item(drive='me', path='all-data').children['sample.xlsx'].upload('sample.xlsx')